]> scm.dxcluster.org Git - spider.git/commitdiff
fix the issue in DXProt::add_thingy
authorDirk Koopman <djk@tobit.co.uk>
Tue, 26 May 2020 18:53:13 +0000 (19:53 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Tue, 26 May 2020 18:53:13 +0000 (19:53 +0100)
For some reason I wasn't checking whether PC92 routing message was valid
enough. I shall probably have to harden it even more still.

Also fixed DXDebug::printdbgring(nn) so that actually honours nn!

cmd/show/debug_ring.pl
perl/DXCommandmode.pm
perl/DXDebug.pm
perl/DXProtHandle.pm
perl/cluster.pl

index 272da35c2bb7d69ca86a07f391c5d7e33ac146d8..9513b9655078aa58a089edfabf913ff0173ad62d 100644 (file)
@@ -12,10 +12,12 @@ my $n;
 my $doclear;
 
 for (@args) {
+       say "arg: $_";
        $n = 0+$_ if /^\d+$/;
        $doclear++ if /^clear$/;
 }
-DXDebug::dbgprintring($n);
+my $lines = DXDebug::dbgprintring($n);
 DXDebug::dbgclearring() if $doclear;
+dge;
 
-return (1, 'Contents of debug ring buffer logged. View with watchdbg.');
+return (1, qq{Contents of $lines lines of debug ring buffer logged. View with watchdbg.});
index a31cc4dee92c82b241941001d67c46530b685fe9..8bb6659e5f0f7fb70e849fb30da9b9150b94e6a9 100644 (file)
@@ -13,7 +13,7 @@ package DXCommandmode;
 
 @ISA = qw(DXChannel);
 
-require 5.10.1;
+use 5.10.1;
 
 use POSIX qw(:math_h);
 use DXUtil;
@@ -835,7 +835,7 @@ sub find_cmd_name {
                };
                
                #wrap the code into a subroutine inside our unique package
-               my $eval = qq(package DXCommandmode::$package; use POSIX qw{:math_h}; use DXLog; use DXDebug; use DXUser; use DXUtil; our \@ISA = qw{DXCommandmode}; );
+               my $eval = qq(package DXCommandmode::$package; use 5.10.1; use POSIX qw{:math_h}; use DXLog; use DXDebug; use DXUser; use DXUtil; our \@ISA = qw{DXCommandmode}; );
 
 
                if ($sub =~ m|\s*sub\s+handle\n|) {
index 25d742250a6572037ee6f4589a2cf54a4bd4a53f..d901c6b5b047bb5a7951bca67b3104d30229b672 100644 (file)
@@ -83,7 +83,7 @@ if (!defined $DB::VERSION) {
 } 
 
 
-my $_isdbg;                                            # current dbg level we are processing
+my $_isdbg = '';                                               # current dbg level we are processing
 
 sub dbg
 {
@@ -218,11 +218,13 @@ sub longmess
 sub dbgprintring
 {
        return unless $fp;
-       my $count = shift;
+       my $i = shift || 0;
+       my $count = @dbgring;
+       $i =  @dbgring-$i if $i;
+       return 0 unless $i < $count;    # do nothing if there is nothing to print
+
        my $first;
        my $l;
-       my $i = defined $count ? @dbgring-$count : 0;
-       $count = @dbgring;
        for ( ; $i < $count; ++$i) {
                my ($t, $str) = split /\^/, $dbgring[$i], 2;
                next unless $t;
@@ -235,11 +237,13 @@ sub dbgprintring
                }
                my $buf = sprintf "%02d:%02d:%02d", (gmtime($t))[2,1,0];
                $fp->writeunix($lt, "$lt^RING: $buf^$str");
+               ++$l;
        }
        my $et = time;
        $fp->writeunix($et, "$et^###");
-       $fp->writeunix($et, "$et^### RINGBUFFER END");
+       $fp->writeunix($et, "$et^### RINGBUFFER END $l debug lines written");
        $fp->writeunix($et, "$et^###");
+       return $l;
 }
 
 sub dbgclearring
index b3278d36a78a835405f2a72bf8adf68d4e7a142f..b75d70843321984180a2a942cccd179f0f5d7c39 100644 (file)
@@ -1489,30 +1489,36 @@ sub _add_thingy
        
        if ($call) {
                my $ncall = $parent->call;
-               if ($is_node) {
-                       dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
-                       @rout = $parent->add($call, $version, Route::here($here), $ip);
-                       my $r = Route::Node::get($call);
-                       $r->PC92C_dxchan($dxchan->call, $hops) if $r;
-                       if ($ip) {
-                               $r->ip($ip);
-                               Log('DXProt', "PC92A $call -> $ip on $ncall");
+               if ($ncall ne $call) {
+                       if ($is_node) {
+                               dbg("ROUTE: added node $call to $ncall") if isdbg('routelow');
+                               @rout = $parent->add($call, $version, Route::here($here), $ip);
+                               my $r = Route::Node::get($call);
+                               $r->PC92C_dxchan($dxchan->call, $hops) if $r;
+                               if ($ip) {
+                                       $r->ip($ip);
+                                       Log('DXProt', "PC92A $call -> $ip on $ncall");
+                               }
+                       } else {
+                               dbg("ROUTE: added user $call to $ncall") if isdbg('routelow');
+                               @rout = $parent->add_user($call, Route::here($here), $ip);
+                               $dxchan->tell_buddies('loginb', $call, $ncall) if $dxchan;
+                               my $r = Route::User::get($call);
+                               if ($ip) {
+                                       $r->ip($ip);
+                                       Log('DXProt', "PC92A $call -> $ip on $ncall");
+                               }
                        }
-               } else {
-                       dbg("ROUTE: added user $call to $ncall") if isdbg('routelow');
-                       @rout = $parent->add_user($call, Route::here($here), $ip);
-                       $dxchan->tell_buddies('loginb', $call, $ncall) if $dxchan;
-                       my $r = Route::User::get($call);
-                       if ($ip) {
-                               $r->ip($ip);
-                               Log('DXProt', "PC92A $call -> $ip on $ncall");
+                       if ($pc92_slug_changes && $parent == $main::routeroot) {
+                               $things_add{$call} = Route::get($call);
+                               delete $things_del{$call};
                        }
-               }
-               if ($pc92_slug_changes && $parent == $main::routeroot) {
-                       $things_add{$call} = Route::get($call);
-                       delete $things_del{$call};
+               } else {
+                       dbgprintring(10);
+                       dbg("DXProt::add_thingy: Trying to add parent $call to itself $ncall, ignored");
                }
        }
+       
        return @rout;
 }
 
index e13fb03493dea1093bb0c1e2844005fad9ed7078..6bd0c7440aeb1f0a9556bfdc0e7c4d2ba690a2e0 100755 (executable)
@@ -13,6 +13,7 @@
 package main;
 
 require 5.10.1;
+
 use warnings;
 
 use vars qw($root $is_win $systime $lockfn @inqueue $starttime $lockfn @outstanding_connects
@@ -33,7 +34,8 @@ $user_interval = 11*60;                       # the interval between unsolicited prompts if no traff
 # make sure that modules are searched in the order local then perl
 BEGIN {
        umask 002;
-
+       $SIG{'__WARN__'} = sub { warn $_[0] if $DOWARN };
+                       
        # take into account any local::lib that might be present
        eval {
                require local::lib;
@@ -87,14 +89,13 @@ BEGIN {
 use DXVars;
 use SysVar;
 
-use strict;
-
 # order here is important - DXDebug snarfs Carp et al so that Mojo errors go into the debug log
 use DXDebug;
-
 use Mojolicious 7.26;
 use Mojo::IOLoop;
 
+$DOWARN = 1;
+
 use Msg;
 use IntMsg;
 use Internet;
@@ -157,6 +158,8 @@ use Web;
 
 use vars qw($version $build $gitversion $gitbranch);
 
+use strict;
+
 use Local;