$systime = time;
}
+use Mojo::IOLoop;
+
use DXVars;
use Msg;
use IntMsg;
$zombies $root @listeners $lang $myalias @debug $userfn $clusteraddr
$clusterport $mycall $decease $is_win $routeroot $me $reqreg $bumpexisting
$allowdxby $dbh $dsn $dbuser $dbpass $do_xml $systime_days $systime_daystart
- $can_encode $maxconnect_user $maxconnect_node
+ $can_encode $maxconnect_user $maxconnect_node $idle_interval
);
@inqueue = (); # the main input queue, an array of hashes
$maxconnect_node = 0; # Ditto but for nodes. In either case if a new incoming connection
# takes the no of references in the routing table above these numbers
# then the connection is refused. This only affects INCOMING connections.
+$idle_interval = 0.100; # the wait between invocations of the main idle loop processing.
# send a message to call on conn and disconnect
sub already_conn
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) {
UDPMsg::finish();
# end everything else
- Msg->event_loop(100, 0.01);
DXUser::finish();
DXDupe::finish();
$l->close_server;
}
- LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitversion) ended");
+ LogDbg('cluster', "DXSpider V$version, build $build (git: $gitversion) ended");
+ dbg("bye bye everyone - bye bye");
dbgclose();
Logclose();
AGWMsg::init(\&new_channel);
}
+sub idle_loop
+{
+ my $timenow = time;
+
+ DXChannel::process();
+
+ # $DB::trace = 0;
+
+ # do timed stuff, ongoing processing happens one a second
+ if ($timenow != $systime) {
+ reap() if $zombies;
+ $systime = $timenow;
+ my $days = int ($systime / 86400);
+ if ($systime_days != $days) {
+ $systime_days = $days;
+ $systime_daystart = $days * 86400;
+ }
+ IsoTime::update($systime);
+ DXCron::process(); # do cron jobs
+ DXCommandmode::process(); # process ongoing command mode stuff
+ DXXml::process();
+ DXProt::process(); # process ongoing ak1a pcxx stuff
+ DXConnect::process();
+ DXMsg::process();
+ DXDb::process();
+ DXUser::process();
+ DXDupe::process();
+ $systime_days = $days;
+ $systime_daystart = $days * 86400;
+ }
+ IsoTime::update($systime);
+ DXCron::process(); # do cron jobs
+ DXCommandmode::process(); # process ongoing command mode stuff
+ DXXml::process();
+ DXProt::process(); # process ongoing ak1a pcxx stuff
+ DXConnect::process();
+ DXMsg::process();
+ DXDb::process();
+ DXUser::process();
+ DXDupe::process();
+ AGWMsg::process();
+ BPQMsg::process();
+
+ Timer::handler();
+
+ if (defined &Local::process) {
+ eval {
+ Local::process(); # do any localised processing
+ };
+ dbg("Local::process error $@") if $@;
+ }
+}
+
+
#############################################################
#
# The start of the main line of code
# banner
my ($year) = (gmtime)[5];
$year += 1900;
-LogDbg('cluster', "DXSpider V$version, build $subversion.$build (git: $gitversion) started");
+LogDbg('cluster', "DXSpider V$version, build $build (git: $gitversion) started");
dbg("Copyright (c) 1998-$year Dirk Koopman G1TLH");
# load Prefixes
# prime some signals
unless ($DB::VERSION) {
- $SIG{INT} = $SIG{TERM} = sub { $decease = 1 };
+ $SIG{INT} = $SIG{TERM} = sub { Mojo::IOLoop->stop; };
}
unless ($is_win) {
#open(DB::OUT, "|tee /tmp/aa");
-for (;;) {
-# $DB::trace = 1;
-
- Msg->event_loop(10, 0.010);
- my $timenow = time;
-
- DXChannel::process();
+my $main_loop = Mojo::IOLoop->recurring($idle_interval => \&idle_loop);
-# $DB::trace = 0;
+Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
- # do timed stuff, ongoing processing happens one a second
- if ($timenow != $systime) {
- reap() if $zombies;
- $systime = $timenow;
- my $days = int ($systime / 86400);
- if ($systime_days != $days) {
- $systime_days = $days;
- $systime_daystart = $days * 86400;
- }
- IsoTime::update($systime);
- DXCron::process(); # do cron jobs
- DXCommandmode::process(); # process ongoing command mode stuff
- DXXml::process();
- DXProt::process(); # process ongoing ak1a pcxx stuff
- DXConnect::process();
- DXMsg::process();
- DXDb::process();
- DXUser::process();
- DXDupe::process();
- AGWMsg::process();
- BPQMsg::process();
-
- if (defined &Local::process) {
- eval {
- Local::process(); # do any localised processing
- };
- dbg("Local::process error $@") if $@;
- }
- }
- if ($decease) {
- last if --$decease <= 0;
- }
-}
cease(0);
exit(0);