X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fcluster.pl;h=cc96ac59b0bf065e2bff69cdd9aa5ba0db5825fa;hb=770092d94f96b6d22a38fb33e0056b4779a8a1ab;hp=f1eade415bc263ae5778b03dec2fcf2e8c9ad4f8;hpb=4b207544da78b182bd12e94eab01451694749012;p=spider.git diff --git a/perl/cluster.pl b/perl/cluster.pl index f1eade41..cc96ac59 100755 --- a/perl/cluster.pl +++ b/perl/cluster.pl @@ -121,6 +121,7 @@ use DXXml; use DXSql; use IsoTime; use BPQMsg; +use DXCIDR; use Data::Dumper; use IO::File; @@ -140,8 +141,8 @@ use vars qw(@inqueue $systime $starttime $lockfn @outstanding_connects ); -$clusteraddr //= '127.0.0.1'; # cluster tcp host address - used for things like console.pl -$clusterport //= 27754; # cluster tcp port +$clusteraddr ||= '127.0.0.1'; # cluster tcp host address - used for things like console.pl +$clusterport ||= 27754; # cluster tcp port @inqueue = (); # the main input queue, an array of hashes $systime = 0; # the time now (in seconds) $starttime = 0; # the starting time of the cluster @@ -271,10 +272,16 @@ sub login } # cease running this program, close down all the connections nicely +our $is_ceasing; + sub cease { my $dxchan; + cluck("ceasing") if $is_ceasing; + + return if $is_ceasing++; + unless ($is_win) { $SIG{'TERM'} = 'IGNORE'; $SIG{'INT'} = 'IGNORE'; @@ -293,13 +300,14 @@ sub cease foreach $dxchan (DXChannel::get_all_nodes) { $dxchan->disconnect(2) unless $dxchan == $main::me; } - Msg->event_loop(100, 0.01); # disconnect users foreach $dxchan (DXChannel::get_all_users) { $dxchan->disconnect; } + Msg->event_loop(100, 0.01); + # disconnect AGW AGWMsg::finish(); BPQMsg::finish(); @@ -309,8 +317,9 @@ sub cease # end everything else Msg->event_loop(100, 0.01); - DXUser::finish(); DXDupe::finish(); + QSL::finish(); + DXUser::finish(); # close all databases DXDb::closeall; @@ -320,12 +329,12 @@ sub cease $l->close_server; } - LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O ended"); + $dbh->finish if $dbh; + + LogDbg("DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O ended"); dbgclose(); Logclose(); - $dbh->finish if $dbh; - unlink $lockfn; # $SIG{__WARN__} = $SIG{__DIE__} = sub {my $a = shift; cluck($a); }; exit(0); @@ -441,7 +450,8 @@ DXXml::init(); my ($year) = (gmtime)[5]; $year += 1900; LogDbg('cluster', "DXSpider v$version build $build (git: $gitbranch/$gitversion) using perl $^V on $^O started"); -dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH"); +LogDbg('cluster', "Copyright (c) 1998-$year Dirk Koopman G1TLH"); +LogDbg('cluster', "Capabilities: ve7cc rbn"); # load Prefixes dbg("loading prefixes ..."); @@ -477,6 +487,9 @@ DXUser->init($userfn, 1); } } +# get any bad IPs +DXCIDR::init(); + # start listening for incoming messages/connects dbg("starting listeners ..."); my $conn = IntMsg->new_server($clusteraddr, $clusterport, \&login); @@ -642,7 +655,12 @@ for (;;) { last if --$decease <= 0; } } -cease(0); +cease(0) unless $is_ceasing; exit(0); +# +sub END +{ + cease(0) unless $is_ceasing; +}