]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/Preforker: fix broken recursion on exit(3)
authorSage Weil <sage@inktank.com>
Sat, 15 Jun 2013 15:14:40 +0000 (08:14 -0700)
committerSage Weil <sage@inktank.com>
Sun, 16 Jun 2013 03:48:05 +0000 (20:48 -0700)
If we exit via preforker, call exit(3) and not recursively back into
Preforker::exit(r).  Otherwise you get a hang with the child blocked
at:

Thread 1 (Thread 0x7fa08962e7c0 (LWP 5419)):
#0  0x000000309860e0cd in write () from /lib64/libpthread.so.0
#1  0x00000000005cc906 in Preforker::exit(int) ()
#2  0x00000000005c8dfb in main ()

and the parent at

#0  0x000000309860eba7 in waitpid () from /lib64/libpthread.so.0
#1  0x00000000005cc87a in Preforker::parent_wait() ()
#2  0x00000000005c75ae in main ()

Backport: cuttlefish
Signed-off-by: Sage Weil <sage@inktank.com>
src/common/Preforker.h

index 20e8b00be151e6455559b11c2d00abd75d94c14a..2c1d4fd6795693d281ff1ca17f8500caa8832897 100644 (file)
@@ -79,13 +79,13 @@ public:
   int signal_exit(int r) {
     if (forked) {
       // tell parent
-      (void)::write(fd[1], &r, sizeof(r));
+      (void)safe_write(fd[1], &r, sizeof(r));
     }
     return r;
   }
   void exit(int r) {
     signal_exit(r);
-    exit(r);
+    ::exit(r);
   }
 
   void daemonize() {