try a different strategy
[spider.git] / perl / cluster.pl
index dfae3278efb914bf5bdc944be1ac91c393a7b2e9..1e850c90f8b9c74a030a1cab913f770d4d86f218 100755 (executable)
@@ -62,9 +62,11 @@ use DXDb;
 use AnnTalk;
 use WCY;
 use DXDupe;
+use BadWords;
 
 use Data::Dumper;
 use Fcntl ':flock'; 
+use POSIX ":sys_wait_h";
 
 use Local;
 
@@ -72,7 +74,7 @@ package main;
 
 @inqueue = ();                                 # the main input queue, an array of hashes
 $systime = 0;                                  # the time now (in seconds)
-$version = "1.44";                             # the version no of the software
+$version = "1.45";                             # the version no of the software
 $starttime = 0;                 # the starting time of the cluster   
 $lockfn = "cluster.lock";       # lock file name
 @outstanding_connects = ();     # list of outstanding connects
@@ -237,9 +239,12 @@ sub cease
 # the reaper of children
 sub reap
 {
-       $SIG{'CHLD'} = \&reap;
-       my $cpid = wait;
-       @outstanding_connects = grep {$_->{pid} != $cpid} @outstanding_connects;
+       my $cpid;
+       while (($cpid = waitpid(1, &WNOHANG)) != -1) {
+               dbg('reap', "cpid: $cpid");
+               @outstanding_connects = grep {$_->{pid} != $cpid} @outstanding_connects;
+       }
+       dbg('reap', "cpid: $cpid");
 }
 
 # this is where the input queue is dealt with and things are dispatched off to other parts of
@@ -323,6 +328,9 @@ DXUser->init($userfn, 1);
 dbg('err', "starting listener ...");
 Msg->new_server("$clusteraddr", $clusterport, \&login);
 
+# load bad words
+dbg('err', "load badwords: " . (BadWords::load or "Ok"));
+
 # prime some signals
 $SIG{INT} = \&cease;
 $SIG{TERM} = \&cease;
@@ -364,7 +372,7 @@ DXProt->init();
 
 
 # put in a DXCluster node for us here so we can add users and take them away
-DXNode->new(0, $mycall, 0, 1, $DXProt::myprot_version); 
+DXNode->new($DXProt::me, $mycall, 0, 1, $DXProt::myprot_version); 
 
 # read in any existing message headers and clean out old crap
 dbg('err', "reading existing message headers ...");