[mogilefs] bradfitz, r438: don't spin in workers in parent process ... (fwd)

Brad Fitzpatrick brad at danga.com
Mon Nov 6 05:51:25 UTC 2006


Alan,

This fixes the spin in children that you saw when your parent process
died.  I could reproduce by kill -9 the parent, and this fixes it.
My bad... was just totally forgotten.  (I had my $rv there, like I was
starting to do it...)

Anyway, still interested in how you got your parent process to die.  If
you could get me an strace tomorrow it should be totally easy to find.

- Brad


---------- Forwarded message ----------
Date: Mon, 6 Nov 2006 05:51:17 +0000 (UTC)
From: commits at code.sixapart.com
To: cvs-commits at livejournal.com
Subject: [mogilefs] bradfitz, r438: don't spin in workers in parent process ...

don't spin in workers in parent process is kill -9 or otherwise killed forcefully



U   trunk/server/lib/MogileFS/Worker/Query.pm
U   trunk/server/lib/MogileFS/Worker.pm


Modified: trunk/server/lib/MogileFS/Worker/Query.pm
===================================================================
--- trunk/server/lib/MogileFS/Worker/Query.pm	2006-11-06 04:10:06 UTC (rev 437)
+++ trunk/server/lib/MogileFS/Worker/Query.pm	2006-11-06 05:51:16 UTC (rev 438)
@@ -53,6 +53,13 @@

         my $newread;
         my $rv = sysread($psock, $newread, 1024);
+        if (!$rv) {
+            if (defined $rv) {
+                die "While reading pipe from parent, got EOF.  Parent's gone.  Quitting.\n";
+            } else {
+                die "Error reading pipe from parent: $!\n";
+            }
+        }
         $buf .= $newread;

         while ($buf =~ s/^(.+?)\r?\n//) {

Modified: trunk/server/lib/MogileFS/Worker.pm
===================================================================
--- trunk/server/lib/MogileFS/Worker.pm	2006-11-06 04:10:06 UTC (rev 437)
+++ trunk/server/lib/MogileFS/Worker.pm	2006-11-06 05:51:16 UTC (rev 438)
@@ -93,6 +93,13 @@
     while (Mgd::wait_for_readability(fileno($psock), 0)) {
         my $buf;
         my $rv = sysread($psock, $buf, 1024);
+        if (!$rv) {
+            if (defined $rv) {
+                die "While reading pipe from parent, got EOF.  Parent's gone.  Quitting.\n";
+            } else {
+                die "Error reading pipe from parent: $!\n";
+            }
+        }
         $self->{readbuf} .= $buf;

         while ($self->{readbuf} =~ s/^(.+?)\r?\n//) {




More information about the mogilefs mailing list