On 12/6/2013 6:48 AM, Brian Smith wrote:
On Thu, Dec 5, 2013 at 9:46 PM, Robert O'Callahan <rob...@ocallahan.org> wrote:
bug 924253
I think we should also be careful that, when we have multiple
processes (which is always, because of e10s-based about:newtab
fetching), that those multiple processes are not clobbering each
other's output, when NSPR_LOG_FILE is used. I am not sure what the
current state of this is.

Cheers,
Brian
It's completely broken and I'm using the attached patch locally in any build I want to log to file for.
-hb-
# HG changeset patch
# Parent d263838ce6f98b15ba06f676fec5a0b31496f8f9
diff --git a/nsprpub/pr/src/io/prlog.c b/nsprpub/pr/src/io/prlog.c
--- a/nsprpub/pr/src/io/prlog.c
+++ b/nsprpub/pr/src/io/prlog.c
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "primpl.h"
 #include "prenv.h"
 #include "prprf.h"
 #include <string.h>
+#include <process.h>
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 
 /*
  * Lock used to lock the log.
  *
  * We can't define _PR_LOCK_LOG simply as PR_Lock because PR_Lock may
@@ -244,25 +245,27 @@ void _PR_InitLog(void)
 #ifdef XP_UNIX
         if ((getuid() != geteuid()) || (getgid() != getegid())) {
             return;
         }
 #endif /* XP_UNIX */
 
         ev = PR_GetEnv("NSPR_LOG_FILE");
         if (ev && ev[0]) {
-            if (!PR_SetLogFile(ev)) {
+            char buf[1024];
+            PR_snprintf(buf, 1023, "%s.%d", ev, _getpid());
+            if (!PR_SetLogFile(buf)) {
 #ifdef XP_PC
-                char* str = PR_smprintf("Unable to create nspr log file 
'%s'\n", ev);
+                char* str = PR_smprintf("Unable to create nspr log file 
'%s'\n", buf);
                 if (str) {
                     OutputDebugStringA(str);
                     PR_smprintf_free(str);
                 }
 #else
-                fprintf(stderr, "Unable to create nspr log file '%s'\n", ev);
+                fprintf(stderr, "Unable to create nspr log file '%s'\n", buf);
 #endif
             }
         } else {
 #ifdef _PR_USE_STDIO_FOR_LOGGING
             logFile = stderr;
 #else
             logFile = _pr_stderr;
 #endif
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to