зеркало из https://github.com/mozilla/gecko-dev.git
Bugzilla bug 96122: use _PR_ShutdownLinker() on all platforms to clean up
the static data created by prlink.c. Parts of this patch were contributed by Jeff Hostetler <jeff@NerdOne.com>. Modified files: _win16.h primpl.h prlink.c prinit.c ptthread.c
This commit is contained in:
Родитель
51ba5208ab
Коммит
0fcc6e185d
|
@ -442,13 +442,6 @@ NSPR_API(void) _PR_NativeDestroyThread(PRThread *thread);
|
|||
NSPR_API(void) _PR_UserDestroyThread(PRThread *thread);
|
||||
|
||||
|
||||
/*
|
||||
* _PR_ShutdownLinker unloads all dlls loaded by the application via
|
||||
* calls to PR_LoadLibrary
|
||||
*/
|
||||
void _PR_ShutdownLinker(void);
|
||||
|
||||
|
||||
/*
|
||||
** If thread emulation is used, then setjmp/longjmp stores the register
|
||||
** state of each thread.
|
||||
|
|
|
@ -1741,6 +1741,7 @@ extern void _PR_InitMW(void);
|
|||
extern void _PR_InitRWLocks(void);
|
||||
extern void _PR_NotifyCondVar(PRCondVar *cvar, PRThread *me);
|
||||
extern void _PR_CleanupThread(PRThread *thread);
|
||||
extern void _PR_ShutdownLinker(void);
|
||||
extern void _PR_CleanupEnv(void);
|
||||
extern void _PR_CleanupIO(void);
|
||||
extern void _PR_CleanupNet(void);
|
||||
|
|
|
@ -262,6 +262,10 @@ void _PR_InitLinker(void)
|
|||
}
|
||||
|
||||
#if defined(WIN16)
|
||||
/*
|
||||
* _PR_ShutdownLinker unloads all dlls loaded by the application via
|
||||
* calls to PR_LoadLibrary
|
||||
*/
|
||||
void _PR_ShutdownLinker(void)
|
||||
{
|
||||
PR_EnterMonitor(pr_linker_lock);
|
||||
|
@ -282,6 +286,32 @@ void _PR_ShutdownLinker(void)
|
|||
PR_DestroyMonitor(pr_linker_lock);
|
||||
pr_linker_lock = NULL;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* _PR_ShutdownLinker was originally only used on WIN16 (see above),
|
||||
* but I think it should also be used on other platforms. However,
|
||||
* I disagree with the original implementation's unloading the dlls
|
||||
* for the application. Any dlls that still remain on the pr_loadmap
|
||||
* list when NSPR shuts down are application programming errors. The
|
||||
* only exception is pr_exe_loadmap, which was added to the list by
|
||||
* NSPR and hence should be cleaned up by NSPR.
|
||||
*/
|
||||
void _PR_ShutdownLinker(void)
|
||||
{
|
||||
/* FIXME: pr_exe_loadmap should be destroyed. */
|
||||
|
||||
PR_DestroyMonitor(pr_linker_lock);
|
||||
pr_linker_lock = NULL;
|
||||
|
||||
if (_pr_currentLibPath) {
|
||||
free(_pr_currentLibPath);
|
||||
_pr_currentLibPath = NULL;
|
||||
}
|
||||
|
||||
#if !defined(USE_DLFCN) && !defined(HAVE_STRERROR)
|
||||
PR_DELETE(errStrBuf);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -292,7 +322,9 @@ PR_IMPLEMENT(PRStatus) PR_SetLibraryPath(const char *path)
|
|||
|
||||
if (!_pr_initialized) _PR_ImplicitInitialization();
|
||||
PR_EnterMonitor(pr_linker_lock);
|
||||
PR_FREEIF(_pr_currentLibPath);
|
||||
if (_pr_currentLibPath) {
|
||||
free(_pr_currentLibPath);
|
||||
}
|
||||
if (path) {
|
||||
_pr_currentLibPath = strdup(path);
|
||||
if (!_pr_currentLibPath) {
|
||||
|
@ -342,7 +374,7 @@ PR_GetLibraryPath()
|
|||
ev = "";
|
||||
|
||||
len = strlen(ev) + 1; /* +1 for the null */
|
||||
p = (char*) PR_MALLOC(len);
|
||||
p = (char*) malloc(len);
|
||||
if (p) {
|
||||
strcpy(p, ev);
|
||||
}
|
||||
|
@ -369,7 +401,7 @@ PR_GetLibraryPath()
|
|||
#endif
|
||||
len = strlen(ev) + 1; /* +1 for the null */
|
||||
|
||||
p = (char*) PR_MALLOC(len);
|
||||
p = (char*) malloc(len);
|
||||
if (p) {
|
||||
strcpy(p, ev);
|
||||
} /* if (p) */
|
||||
|
@ -1148,7 +1180,8 @@ PR_UnloadLibrary(PRLibrary *lib)
|
|||
|
||||
freeLib:
|
||||
PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Unloaded library %s", lib->name));
|
||||
PR_DELETE(lib->name);
|
||||
free(lib->name);
|
||||
lib->name = NULL;
|
||||
PR_DELETE(lib);
|
||||
if (result == -1) {
|
||||
PR_SetError(PR_UNLOAD_LIBRARY_ERROR, _MD_ERRNO());
|
||||
|
|
|
@ -417,9 +417,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
|
|||
PR_ASSERT((_PR_IS_NATIVE_THREAD(me)) || (me->cpu->id == 0));
|
||||
#endif
|
||||
|
||||
#if defined(WIN16)
|
||||
_PR_ShutdownLinker();
|
||||
#endif
|
||||
/* Release the primordial thread's private data, etc. */
|
||||
_PR_CleanupThread(me);
|
||||
|
||||
|
|
|
@ -920,6 +920,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
|
|||
PR_WaitCondVar(pt_book.cv, PR_INTERVAL_NO_TIMEOUT);
|
||||
PR_Unlock(pt_book.ml);
|
||||
|
||||
_PR_ShutdownLinker();
|
||||
_PR_LogCleanup();
|
||||
_PR_CleanupNet();
|
||||
/* Close all the fd's before calling _PR_CleanupIO */
|
||||
|
|
Загрузка…
Ссылка в новой задаче