Started the new routing stuff which will run in parallel for a while.
[spider.git] / perl / DXMsg.pm
index 501d137d1454ba49bdc971312cffbfd39c1bc0c8..d5631904971148fae3c246cbff338d4033b4cb2b 100644 (file)
@@ -15,8 +15,6 @@
 
 package DXMsg;
 
-@ISA = qw(DXProt DXChannel);
-
 use DXUtil;
 use DXChannel;
 use DXUser;
@@ -131,20 +129,6 @@ sub process
 
                if ($main::systime >= $lastq + $queueinterval) {
 
-                       # wander down the work queue stopping any messages that have timed out
-                       for (keys %busy) {
-                               my $node = $_;
-                               my $ref = $busy{$_};
-                               if (exists $ref->{lastt} && $main::systime >= $ref->{lastt} + $timeout) {
-                                       dbg('msg', "Timeout, stopping msgno: $ref->{msgno} -> $node");
-                                       Log('msg', "Timeout, stopping msgno: $ref->{msgno} -> $node");
-                                       $ref->stop_msg($node);
-                                       
-                                       # delay any outgoing messages that fail
-                                       $ref->{waitt} = $main::systime + $waittime + rand(120) if $node ne $main::mycall;
-                               }
-                       }
-
                        # queue some message if the interval timer has gone off
                        queue_msg(0);
 
@@ -287,8 +271,7 @@ sub process
                                                $ref->swop_it($self->call);
                                                
                                                # look for 'bad' to addresses 
-#                                              if (grep $ref->{to} eq $_, @badmsg) {
-                                               if ($ref->dump_it($self->call)) {
+                                               if ($ref->dump_it) {
                                                        $ref->stop_msg($self->call);
                                                        dbg('msg', "'Bad' message $ref->{to}");
                                                        Log('msg', "'Bad' message $ref->{to}");
@@ -594,8 +577,6 @@ sub queue_msg
        dbg('msg', "queue msg ($sort)\n");
        my @nodelist = DXChannel::get_all_nodes;
        foreach $ref (@msg) {
-               # firstly, is it private and unread? if so can I find the recipient
-               # in my cluster node list offsite?
 
                # ignore 'delayed' messages until their waiting time has expired
                if (exists $ref->{waitt}) {
@@ -603,6 +584,22 @@ sub queue_msg
                        delete $ref->{waitt};
                } 
 
+               # any time outs?
+               if (exists $ref->{lastt} && $main::systime >= $ref->{lastt} + $timeout) {
+                       my $node = $ref->{tonode};
+                       dbg('msg', "Timeout, stopping msgno: $ref->{msgno} -> $node");
+                       Log('msg', "Timeout, stopping msgno: $ref->{msgno} -> $node");
+                       $ref->stop_msg($node);
+                       
+                       # delay any outgoing messages that fail
+                       $ref->{waitt} = $main::systime + $waittime + rand(120) if $node ne $main::mycall;
+                       delete $ref->{lastt};
+                       next;
+               }
+
+               # firstly, is it private and unread? if so can I find the recipient
+               # in my cluster node list offsite?
+
                # deal with routed private messages
                my $dxchan;
                if ($ref->{private}) {
@@ -761,7 +758,7 @@ sub init
                }
                
                # delete any messages to 'badmsg.pl' places
-               if (grep $ref->{to} eq $_, @badmsg) {
+               if ($ref->dump_it) {
                        dbg('msg', "'Bad' TO address $ref->{to}");
                        Log('msg', "'Bad' TO address $ref->{to}");
                        $ref->del_msg;
@@ -976,7 +973,6 @@ sub forward_it
 sub dump_it
 {
        my $ref = shift;
-       my $call = shift;
        my $i;
        
        for ($i = 0; $i < @badmsg; $i += 3) {