зеркало из https://github.com/mozilla/pjs.git
Bugzilla Bug 354593: fixed a race condition in the creation of the lock
that protects localtime() by creating the lock during NSPR initialization. r=aleksey.sanin,nelson.bolyard. The patch is contributed by Mark Stevans <marks@coral8.com>. Modified files: primpl.h prinit.c prtime.c ptthread.c
This commit is contained in:
Родитель
59a89981a6
Коммит
f7a561f220
|
@ -1792,12 +1792,14 @@ extern void _PR_InitLinker(void);
|
|||
extern void _PR_InitAtomic(void);
|
||||
extern void _PR_InitCPUs(void);
|
||||
extern void _PR_InitDtoa(void);
|
||||
extern void _PR_InitTime(void);
|
||||
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_CleanupCallOnce(void);
|
||||
extern void _PR_CleanupMW(void);
|
||||
extern void _PR_CleanupTime(void);
|
||||
extern void _PR_CleanupDtoa(void);
|
||||
extern void _PR_ShutdownLinker(void);
|
||||
extern void _PR_CleanupEnv(void);
|
||||
|
|
|
@ -241,6 +241,7 @@ static void _PR_InitStuff(void)
|
|||
_PR_InitLinker();
|
||||
_PR_InitCallOnce();
|
||||
_PR_InitDtoa();
|
||||
_PR_InitTime();
|
||||
_PR_InitMW();
|
||||
_PR_InitRWLocks();
|
||||
|
||||
|
@ -420,6 +421,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
|
|||
#endif
|
||||
|
||||
_PR_CleanupMW();
|
||||
_PR_CleanupTime();
|
||||
_PR_CleanupDtoa();
|
||||
_PR_CleanupCallOnce();
|
||||
_PR_ShutdownLinker();
|
||||
|
|
|
@ -547,6 +547,7 @@ PR_NormalizeTime(PRExplodedTime *time, PRTimeParamFn params)
|
|||
extern struct tm *Maclocaltime(const time_t * t);
|
||||
#endif
|
||||
|
||||
#define _PR_HAVE_LOCALTIME_MONITOR 1
|
||||
static PRLock *monitor = NULL;
|
||||
|
||||
static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
|
||||
|
@ -556,12 +557,7 @@ static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
|
|||
* against NSPR threads only when the
|
||||
* NSPR thread system is activated. */
|
||||
|
||||
if (needLock) {
|
||||
if (monitor == NULL) {
|
||||
monitor = PR_NewLock();
|
||||
}
|
||||
PR_Lock(monitor);
|
||||
}
|
||||
if (needLock) PR_Lock(monitor);
|
||||
|
||||
/*
|
||||
* Microsoft (all flavors) localtime() returns a NULL pointer if 'clock'
|
||||
|
@ -606,6 +602,21 @@ static struct tm *MT_safe_localtime(const time_t *clock, struct tm *result)
|
|||
|
||||
#endif /* definition of MT_safe_localtime() */
|
||||
|
||||
void _PR_InitTime(void)
|
||||
{
|
||||
#ifdef _PR_HAVE_LOCALTIME_MONITOR
|
||||
monitor = PR_NewLock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void _PR_CleanupTime(void)
|
||||
{
|
||||
#ifdef _PR_HAVE_LOCALTIME_MONITOR
|
||||
PR_DestroyLock(monitor);
|
||||
monitor = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_PC) || defined(XP_BEOS)
|
||||
|
||||
PR_IMPLEMENT(PRTimeParameters)
|
||||
|
|
|
@ -938,6 +938,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup(void)
|
|||
PR_Unlock(pt_book.ml);
|
||||
|
||||
_PR_CleanupMW();
|
||||
_PR_CleanupTime();
|
||||
_PR_CleanupDtoa();
|
||||
_PR_CleanupCallOnce();
|
||||
_PR_ShutdownLinker();
|
||||
|
|
Загрузка…
Ссылка в новой задаче