Bug 431805: fixed the leak of the primordial thread's error stack. The

patch is contributed by Boying Lu <brian.lu@sun.com>.  r=wtc.
Modified files: base/base.h base/error.c nss/nssinit.c
This commit is contained in:
wtc%google.com 2008-05-10 01:03:18 +00:00
Родитель 9cbc963857
Коммит 52654fad56
3 изменённых файлов: 38 добавлений и 3 удалений

Просмотреть файл

@ -38,7 +38,7 @@
#define BASE_H
#ifdef DEBUG
static const char BASE_CVS_ID[] = "@(#) $RCSfile: base.h,v $ $Revision: 1.19 $ $Date: 2008-02-23 05:29:23 $";
static const char BASE_CVS_ID[] = "@(#) $RCSfile: base.h,v $ $Revision: 1.20 $ $Date: 2008-05-10 01:03:14 $";
#endif /* DEBUG */
/*
@ -574,6 +574,18 @@ nss_ClearErrorStack
void
);
/*
* nss_DestroyErrorStack
*
* This routine frees the calling thread's error stack.
*/
NSS_EXTERN void
nss_DestroyErrorStack
(
void
);
/*
* NSSItem
*

Просмотреть файл

@ -35,7 +35,7 @@
* ***** END LICENSE BLOCK ***** */
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: error.c,v $ $Revision: 1.7 $ $Date: 2005-12-19 17:53:28 $";
static const char CVS_ID[] = "@(#) $RCSfile: error.c,v $ $Revision: 1.8 $ $Date: 2008-05-10 01:03:15 $";
#endif /* DEBUG */
/*
@ -284,3 +284,18 @@ nss_ClearErrorStack ( void)
es->stack[0] = 0;
return;
}
/*
* nss_DestroyErrorStack
*
* This routine frees the calling thread's error stack.
*/
NSS_IMPLEMENT void
nss_DestroyErrorStack ( void)
{
if( 0 != error_stack_index ) {
PR_SetThreadPrivate(error_stack_index, NULL);
}
return;
}

Просмотреть файл

@ -36,7 +36,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* $Id: nssinit.c,v 1.94 2008-03-26 18:49:04 alexei.volkov.bugs%sun.com Exp $ */
/* $Id: nssinit.c,v 1.95 2008-05-10 01:03:18 wtc%google.com Exp $ */
#include <ctype.h>
#include "seccomon.h"
@ -898,6 +898,14 @@ NSS_Shutdown(void)
shutdownRV = SECFailure;
}
pk11sdr_Shutdown();
/*
* A thread's error stack is automatically destroyed when the thread
* terminates except for the primordial thread, which must call
* PR_Cleanup. Since NSS is usually initialized by the primordial
* thread, and many NSS-based apps don't call PR_Cleanup, we destroy
* the error stack here.
*/
nss_DestroyErrorStack();
nssArena_Shutdown();
if (status == PR_FAILURE) {
if (NSS_GetError() == NSS_ERROR_BUSY) {