[Midnightbsd-cvs] mports: magus.pl: Fix various bugs found in the last run.

ctriv at midnightbsd.org ctriv at midnightbsd.org
Wed Oct 8 10:34:29 EDT 2008


Log Message:
-----------
Fix various bugs found in the last run.

Modified Files:
--------------
    mports/Tools/magus/slave:
        magus.pl (r1.30 -> r1.31)

-------------- next part --------------
Index: magus.pl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/slave/magus.pl,v
retrieving revision 1.30
retrieving revision 1.31
diff -L Tools/magus/slave/magus.pl -L Tools/magus/slave/magus.pl -u -r1.30 -r1.31
--- Tools/magus/slave/magus.pl
+++ Tools/magus/slave/magus.pl
@@ -155,6 +155,8 @@
 
 sub main {
   my $parentPID = $$;
+
+  init_chroot();
   
   MAIN: while (1) {
     if (@DeadChildren) {
@@ -253,14 +255,17 @@
 
 sub process_dead_children {
   while (@DeadChildren) {
-    my $corpse = shift @DeadChildren;
+    my $corpse = $DeadChildren[0];
 
     if ($corpse->{exitcode} == 6) {
       $Logger->info("Child $corpse->{pid} lost database connection.  Reseting %s", $corpse->{lock}->port);
       $corpse->{lock}->port->reset;
-    } else {
-      $corpse->{lock}->delete;
-    }  
+    } 
+    
+    $corpse->{lock}->delete;
+    
+    # we do this last, so if a DBI exception was thrown while clearing the lock, we try again later.
+    shift @DeadChildren;
   }
 }      
     
@@ -376,6 +381,24 @@
   print $fh "$$\n";
   close($fh) || die "Couldn't close $file: $!\n";
 }
+
+
+=head2 init_chroot()
+
+Get the reference dir for the chroot set up so the children don't get 
+into a race trying to do it.
+
+=cut
+
+sub init_chroot {
+  local $SIG{CHLD} = 'DEFAULT';
+  Magus::Chroot->new(
+    workerid => 1,
+    tarball  => $Magus::Config{ChrootTarBall},
+  );
+}
+
+  
     
 1;
 __END__


More information about the Midnightbsd-cvs mailing list