summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2001-09-07 01:55:49 +0000
committerwtc%netscape.com <devnull@localhost>2001-09-07 01:55:49 +0000
commit589768e9652ce073277113f72d56bb2a8cb1a085 (patch)
tree8190c44c0784e65f389d10577cf5d31dc639d0bc
parentca1525eedbe6047ac1561cf2b5d2acb0910a40c6 (diff)
downloadnspr-hg-589768e9652ce073277113f72d56bb2a8cb1a085.tar.gz
Bugzilla bug 95836: Added _PR_CleanupIO() and made it call
_PR_CleanupFdCache(). PR_Cleanup() now calls _PR_CleanupIO() and does not call _PR_CleanupFdCache() directly. Modified files: primpl.h prio.c prinit.c ptio.c ptthread.c
-rw-r--r--pr/include/private/primpl.h1
-rw-r--r--pr/src/io/prio.c21
-rw-r--r--pr/src/misc/prinit.c2
-rw-r--r--pr/src/pthreads/ptio.c28
-rw-r--r--pr/src/pthreads/ptthread.c4
5 files changed, 53 insertions, 3 deletions
diff --git a/pr/include/private/primpl.h b/pr/include/private/primpl.h
index 266595f0..e1834188 100644
--- a/pr/include/private/primpl.h
+++ b/pr/include/private/primpl.h
@@ -1736,6 +1736,7 @@ extern void _PR_InitRWLocks(void);
extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
extern void _PR_CleanupThread(PRThread *thread);
extern void _PR_CleanupEnv(void);
+extern void _PR_CleanupIO(void);
extern void _PR_CleanupLayerCache(void);
extern void _PR_CleanupStacks(void);
extern void _PR_CleanupThreads(void);
diff --git a/pr/src/io/prio.c b/pr/src/io/prio.c
index ce5c021b..250d9b6f 100644
--- a/pr/src/io/prio.c
+++ b/pr/src/io/prio.c
@@ -75,6 +75,27 @@ void _PR_InitIO(void)
_PR_MD_INIT_IO();
}
+void _PR_CleanupIO(void)
+{
+ PR_FreeFileDesc(_pr_stdin);
+ _pr_stdin = NULL;
+ PR_FreeFileDesc(_pr_stdout);
+ _pr_stdout = NULL;
+ PR_FreeFileDesc(_pr_stderr);
+ _pr_stderr = NULL;
+
+ if (_pr_flock_cv) {
+ PR_DestroyCondVar(_pr_flock_cv);
+ _pr_flock_cv = NULL;
+ }
+ if (_pr_flock_lock) {
+ PR_DestroyLock(_pr_flock_lock);
+ _pr_flock_lock = NULL;
+ }
+
+ _PR_CleanupFdCache();
+}
+
PR_IMPLEMENT(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD osfd)
{
PRFileDesc *result = NULL;
diff --git a/pr/src/misc/prinit.c b/pr/src/misc/prinit.c
index 35b1375f..c7471367 100644
--- a/pr/src/misc/prinit.c
+++ b/pr/src/misc/prinit.c
@@ -424,7 +424,6 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
PR_LOG(_pr_thread_lm, PR_LOG_MIN,
("PR_Cleanup: clean up before destroying thread"));
_PR_LogCleanup();
- _PR_CleanupFdCache();
/*
* This part should look like the end of _PR_NativeRunThread
@@ -446,6 +445,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
* Ideally, for each _PR_InitXXX(), there should be a corresponding
* _PR_XXXCleanup() that we can call here.
*/
+ _PR_CleanupIO();
_PR_CleanupThreads();
PR_DestroyLock(_pr_sleeplock);
_pr_sleeplock = NULL;
diff --git a/pr/src/pthreads/ptio.c b/pr/src/pthreads/ptio.c
index c51dd02c..6a2e9903 100644
--- a/pr/src/pthreads/ptio.c
+++ b/pr/src/pthreads/ptio.c
@@ -1080,6 +1080,34 @@ void _PR_InitIO()
} /* _PR_InitIO */
+void _PR_CleanupIO(void)
+{
+ _PR_Putfd(_pr_stdin);
+ _pr_stdin = NULL;
+ _PR_Putfd(_pr_stdout);
+ _pr_stdout = NULL;
+ _PR_Putfd(_pr_stderr);
+ _pr_stderr = NULL;
+
+ _PR_CleanupFdCache();
+
+ if (_pr_flock_cv)
+ {
+ PR_DestroyCondVar(_pr_flock_cv);
+ _pr_flock_cv = NULL;
+ }
+ if (_pr_flock_lock)
+ {
+ PR_DestroyLock(_pr_flock_lock);
+ _pr_flock_lock = NULL;
+ }
+ if (_pr_rename_lock)
+ {
+ PR_DestroyLock(_pr_rename_lock);
+ _pr_rename_lock = NULL;
+ }
+} /* _PR_CleanupIO */
+
PR_IMPLEMENT(PRFileDesc*) PR_GetSpecialFD(PRSpecialFD osfd)
{
PRFileDesc *result = NULL;
diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c
index 264e28db..1072df2d 100644
--- a/pr/src/pthreads/ptthread.c
+++ b/pr/src/pthreads/ptthread.c
@@ -921,8 +921,8 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
PR_Unlock(pt_book.ml);
_PR_LogCleanup();
- /* Close all the fd's before calling _PR_CleanupFdCache */
- _PR_CleanupFdCache();
+ /* Close all the fd's before calling _PR_CleanupIO */
+ _PR_CleanupIO();
/*
* I am not sure if it's safe to delete the cv and lock here,