But 535564 part 3 - don't inherit leak/bloat log handles from parent to child processes on Windows: the Java plugin spawns a process which can remain after our Firefox/plugin processes are properly cleaned up, preventing the log files from being closed, r=jgriffin over IRC
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 27 Jan 2010 11:19:50 -0500
changeset 37549 844ece3e9dfaf66aa14997a3e113d2123725e5ff
parent 37548 d46a66a8c9176f4beb17def7ae95fffafc916b1b
child 37550 6a942d99ce1e3c78a19c877b4622be47eb4bfb8b
push id11371
push userbsmedberg@mozilla.com
push dateWed, 27 Jan 2010 16:56:23 +0000
treeherdermozilla-central@ae8c17be0129 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs535564
milestone1.9.3a1pre
But 535564 part 3 - don't inherit leak/bloat log handles from parent to child processes on Windows: the Java plugin spawns a process which can remain after our Firefox/plugin processes are properly cleaned up, preventing the log files from being closed, r=jgriffin over IRC
xpcom/base/nsTraceRefcntImpl.cpp
--- a/xpcom/base/nsTraceRefcntImpl.cpp
+++ b/xpcom/base/nsTraceRefcntImpl.cpp
@@ -615,16 +615,22 @@ static void RecycleSerialNumberPtr(void*
   PL_HashTableRemove(gSerialNumbers, aPtr);
 }
 
 static PRBool LogThisObj(PRInt32 aSerialNumber)
 {
   return nsnull != PL_HashTableLookup(gObjectsToLog, (const void*)(aSerialNumber));
 }
 
+#ifdef XP_WIN
+#define FOPEN_NO_INHERIT "N"
+#else
+#define FOPEN_NO_INHERIT
+#endif
+
 static PRBool InitLog(const char* envVar, const char* msg, FILE* *result)
 {
   const char* value = getenv(envVar);
   if (value) {
     if (nsCRT::strcmp(value, "1") == 0) {
       *result = stdout;
       fprintf(stdout, "### %s defined -- logging %s to stdout\n",
               envVar, msg);
@@ -648,17 +654,17 @@ static PRBool InitLog(const char* envVar
         fname.AppendLiteral("_");
         fname.Append((char*)XRE_ChildProcessTypeToString(XRE_GetProcessType()));
         fname.AppendLiteral("_pid");
         fname.AppendInt((PRUint32)getpid());
         if (hasLogExtension)
           fname.AppendLiteral(".log");
       }
 #endif
-      stream = ::fopen(fname.get(), "w");
+      stream = ::fopen(fname.get(), "w" FOPEN_NO_INHERIT);
       if (stream != NULL) {
         *result = stream;
         fprintf(stdout, "### %s defined -- logging %s to %s\n",
                 envVar, msg, fname.get());
       }
       else {
         fprintf(stdout, "### %s defined -- unable to log %s to %s\n",
                 envVar, msg, fname.get());