X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCron.pm;h=42dbe2a5d6053d951db5cff878df0e8cae8e6652;hb=9bba449d12641232d51d259f470ce6b21205c622;hp=d2e434bcbbd5bc1d1a4555ec7dd101e0d3d729a3;hpb=465426f9282b990ec3462c63e5ca7613f92fb290;p=spider.git diff --git a/perl/DXCron.pm b/perl/DXCron.pm index d2e434bc..42dbe2a5 100644 --- a/perl/DXCron.pm +++ b/perl/DXCron.pm @@ -13,7 +13,6 @@ use DXUtil; use DXM; use DXDebug; use IO::File; -use Carp; use strict; @@ -218,14 +217,7 @@ sub disconnect { my $call = uc shift; my $dxchan = DXChannel->get($call); - if ($dxchan) { - if ($dxchan->is_ak1a) { - $dxchan->send_now("D", DXProt::pc39($main::mycall, "$main::mycall DXCron")); - } else { - $dxchan->send_now('D', ""); - } - $dxchan->disconnect; - } + $dxchan->disconnect if $dxchan; } # start a connect process off @@ -234,33 +226,15 @@ sub start_connect my $call = uc shift; my $lccall = lc $call; - if (grep {$_->{call} eq $call} @main::outstanding_connects) { + if (Msg->conns($call)) { dbg('cron', "Connect not started, outstanding connect to $call"); return; } - - my $prog = "$main::root/local/client.pl"; - $prog = "$main::root/perl/client.pl" if ! -e $prog; - - my $pid = fork(); - if (defined $pid) { - if (!$pid) { - # in child, unset warnings, disable debugging and general clean up from us - $^W = 0; - eval "{ package DB; sub DB {} }"; - $SIG{HUP} = 'IGNORE'; - alarm(0); - DXChannel::closeall(); - $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT'; - exec $prog, $call, 'connect' or dbg('cron', "exec '$prog' failed $!"); - } - dbg('cron', "connect to $call started"); + if (-e "$main::root/connect/$lccall") { + ExtMsg::start_connect($call, "$main::root/connect/$lccall"); } else { - dbg('cron', "can't fork for $prog $!"); + dbg('err', "Cannot find connect script for $lccall"); } - - # coordinate - sleep(1); } # spawn any old job off @@ -274,10 +248,15 @@ sub spawn # in child, unset warnings, disable debugging and general clean up from us $^W = 0; eval "{ package DB; sub DB {} }"; - $SIG{HUP} = 'IGNORE'; - alarm(0); DXChannel::closeall(); - $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT'; + for (@main::listeners) { + $_->close_server; + } + unless ($main::is_win) { + $SIG{HUP} = 'IGNORE'; + $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT'; + alarm(0); + } exec "$line" or dbg('cron', "exec '$line' failed $!"); } dbg('cron', "spawn of $line started"); @@ -300,7 +279,7 @@ sub rcmd return if !$noderef || !$noderef->pcversion; # send it - DXProt::addrcmd($main::mycall, $call, $line); + DXProt::addrcmd($DXProt::me, $call, $line); } 1; __END__