Bug 658840 - let glxtest process return from XRE_main rather than calling exit() - r=bsmedberg
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 10 Jun 2011 15:07:54 -0400
changeset 70865 84636464bba8
parent 70864 569aed0a1d49
child 70883 28217403cd02
push id20434
push userbjacob@mozilla.com
push dateFri, 10 Jun 2011 19:11:26 +0000
treeherdermozilla-central@84636464bba8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs658840
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 658840 - let glxtest process return from XRE_main rather than calling exit() - r=bsmedberg Calling exit() resulted in two strings being considered leaked by valgrind. Returning from XRE_main() should fix that.
toolkit/xre/glxtest.cpp
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/glxtest.cpp
+++ b/toolkit/xre/glxtest.cpp
@@ -215,32 +215,36 @@ static void glxtest()
   ///// possible.
   glXDestroyContext(dpy, context);
   glXDestroyPixmap(dpy, glxpixmap);
   XFreePixmap(dpy, pixmap);
   XCloseDisplay(dpy);
   dlclose(libgl);
 }
 
-void fire_glxtest_process()
+/** \returns true in the child glxtest process, false in the parent process */
+bool fire_glxtest_process()
 {
   int pfd[2];
   if (pipe(pfd) == -1) {
       perror("pipe");
-      exit(EXIT_FAILURE);
+      return false;
   }
   pid_t pid = fork();
   if (pid < 0) {
       perror("fork");
-      exit(EXIT_FAILURE);
+      close(pfd[0]);
+      close(pfd[1]);
+      return false;
   }
   if (pid == 0) {
       close(pfd[0]);
       write_end_of_the_pipe = pfd[1];
       glxtest();
       close(pfd[1]);
-      exit(EXIT_SUCCESS);
+      return true;
   }
 
   close(pfd[1]);
   mozilla::widget::glxtest_pipe = pfd[0];
   mozilla::widget::glxtest_pid = pid;
+  return false;
 }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2714,17 +2714,17 @@ static DWORD InitDwriteBG(LPVOID lpdwThr
   return 0;
 }
 #endif
 
 PRTime gXRE_mainTimestamp = 0;
 
 #ifdef MOZ_X11
 #ifndef MOZ_PLATFORM_MAEMO
-void fire_glxtest_process();
+bool fire_glxtest_process();
 #endif
 #endif
 
 int
 XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
 {
   NS_TIME_FUNCTION;
 
@@ -2744,17 +2744,18 @@ XRE_main(int argc, char* argv[], const n
 #endif
 
   // see bug 639842
   // it's very important to fire this process BEFORE we set up error handling.
   // indeed, this process is expected to be crashy, and we don't want the user to see its crashes.
   // That's the whole reason for doing this in a separate process.
 #ifdef MOZ_X11
 #ifndef MOZ_PLATFORM_MAEMO
-  fire_glxtest_process();
+  if (fire_glxtest_process())
+    return 0;
 #endif
 #endif
 
 #ifdef XP_WIN
   // Vista API.  Mozilla is DPI Aware.
   typedef BOOL (*SetProcessDPIAwareFunc)(VOID);
 
   SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)