зеркало из https://github.com/mozilla/pjs.git
Bug 529134: Initialize tracemalloc in NS_LogInit() to ensure that tracemalloc is always thread safe. r=bsmedberg r=dbaron
This commit is contained in:
Родитель
ccad2d2dee
Коммит
efd235a889
|
@ -1477,6 +1477,12 @@ NS_TraceMallocStartupArgs(int argc, char **argv)
|
|||
return argc;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(PRBool)
|
||||
NS_TraceMallocHasStarted(void)
|
||||
{
|
||||
return tmlock ? PR_TRUE : PR_FALSE;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
NS_TraceMallocShutdown(void)
|
||||
{
|
||||
|
|
|
@ -164,6 +164,11 @@ PR_EXTERN(void) NS_TraceMallocStartup(int logfd);
|
|||
*/
|
||||
PR_EXTERN(int) NS_TraceMallocStartupArgs(int argc, char* argv[]);
|
||||
|
||||
/**
|
||||
* Return PR_TRUE iff |NS_TraceMallocStartup[Args]| has been successfully called.
|
||||
*/
|
||||
PR_EXTERN(PRBool) NS_TraceMallocHasStarted(void);
|
||||
|
||||
/**
|
||||
* Stop all malloc tracing, flushing any buffered events to the logfile.
|
||||
*/
|
||||
|
|
|
@ -61,6 +61,10 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NS_TRACE_MALLOC
|
||||
#include "nsTraceMalloc.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBDL
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
@ -900,6 +904,13 @@ NS_LogInit()
|
|||
if (++gInitCount)
|
||||
nsTraceRefcntImpl::SetActivityIsLegal(PR_TRUE);
|
||||
#endif
|
||||
|
||||
#ifdef NS_TRACE_MALLOC
|
||||
// XXX we don't have to worry about shutting down trace-malloc; it
|
||||
// handles this itself, through an atexit() callback.
|
||||
if (!NS_TraceMallocHasStarted())
|
||||
NS_TraceMallocStartup(-1); // -1 == no logging
|
||||
#endif
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(void)
|
||||
|
|
Загрузка…
Ссылка в новой задаче