]> dxcluster.net Git - spider.git/commitdiff
fix new pc9x midnight rollover bug
authorDirk Koopman <djk@tobit.co.uk>
Tue, 9 Oct 2007 14:27:00 +0000 (15:27 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Tue, 9 Oct 2007 14:27:00 +0000 (15:27 +0100)
Changes
perl/DXProtHandle.pm
perl/Route/Node.pm
perl/Version.pm
perl/test_lastid.pl [new file with mode: 0755]

diff --git a/Changes b/Changes
index 2a1f37d32641cf456ad03b7a44d481dd59dc46b1..828c428403bbe8b5c25478d1272f22e4d566f409 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+09Oct07=======================================================================
+1. Added *VERY* important change to prevent loops on PC9x sentences.
 06Oct07=======================================================================
 1. added the possibility of having a motd_ax25 especially for sending to
 radio connections after a suggestion by Paolo YV1DIG.
index d73bbc62c77a448aaed8278d61025daed5654b97..7db433e5205f8273c6a00bc5d7f9fbc624a0147f 100644 (file)
@@ -49,7 +49,7 @@ use vars qw($pc11_max_age $pc23_max_age $last_pc50 $eph_restime $eph_info_restim
 
 $pc9x_past_age = 62*60;                        # maximum age in the past of a px9x (a config record might be the only
                                                                # thing a node might send - once an hour)
-$pc9x_future_age = 5*60;               # maximum age in the future ditto
+$pc9x_future_age = 2*3600;             # maximum age in the future ditto
 $pc10_dupe_age = 45;                   # just something to catch duplicate PC10->PC93 conversions
 $pc92_slug_changes = 60;               # slug any changes going outward for this long
 $last_pc92_slug = 0;                   # the last time we sent out any delayed add or del PC92s
@@ -1485,20 +1485,22 @@ sub check_pc9x_t
                # the id on it is completely unreliable. Besides, only commands
                # originating on this box will go through this code...
                if ($parent->call ne $main::mycall) {
-                       my $lastid = $parent->lastid || 0;
-                       if ($t < $lastid) {
-                               if ($t+86400-$lastid > $pc9x_past_age) {
-                                       dbg("PCPROT: dup id on $t <= $lastid, ignored") if isdbg('chanerr');
-                                       return;
-                               }
-                       } elsif ($t == $lastid) {
-                               dbg("PCPROT: dup id on $t == $lastid, ignored") if isdbg('chanerr');
-                               return;
-                       } else {
-                               # $t > $lastid, check that the timestamp offered isn't too far away from 'now'
-                               if ($t+$main::systime_daystart-$main::systime > $pc9x_future_age ) {
-                                       dbg("PCPROT: id $t too far in the future, ignored") if isdbg('chanerr');
+                       my $lastid = $parent->lastid;
+                       if (defined $lastid) {
+                               if ($t < $lastid) {
+                                       if ($t+86400-$lastid > $pc9x_past_age) {
+                                               dbg("PCPROT: dup id on $t <= lastid $lastid, ignored") if isdbg('chanerr');
+                                               return;
+                                       }
+                               } elsif ($t == $lastid) {
+                                       dbg("PCPROT: dup id on $t == lastid $lastid, ignored") if isdbg('chanerr');
                                        return;
+                               } else {
+                                       # $t > $lastid, check that the timestamp offered isn't too far away from 'now'
+                                       if ($t-$lastid > $pc9x_future_age ) {
+                                               dbg("PCPROT: id $t too far in the future of lastid $lastid, ignored") if isdbg('chanerr');
+                                               return;
+                                       }
                                }
                        }
                }
index 6e7d931541c89d48722085be2c8363848e640b93..23e293820295f6c8f4379373e8a85ae5c0481181 100644 (file)
@@ -286,7 +286,6 @@ sub new
        $self->{flags} = shift || Route::here(1);
        $self->{users} = [];
        $self->{nodes} = [];
-       $self->{lastid} = 0;
        $self->{PC92C_dxchan} = '';
        $self->reset_obs;                       # by definition
 
index a0cbffaefa9e81577dfc76a978c18ebc414d20fd..23503da1f787af246530e8d2198db92a27c55ae1 100644 (file)
@@ -11,6 +11,6 @@ use vars qw($version $subversion $build);
 
 $version = '1.54';
 $subversion = '0';
-$build = '164';
+$build = '165';
 
 1;
diff --git a/perl/test_lastid.pl b/perl/test_lastid.pl
new file mode 100755 (executable)
index 0000000..1bd0ea3
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+
+my $pc9x_past_age = 3600;
+my $pc9x_future_age = 3600*2;
+my $lastid;
+
+try($_) for qw(85955 85968 518 85967 519 85968 520 85969), @ARGV;
+
+exit 0;
+
+sub try
+{
+       my $t = shift;
+
+       print "$t : ";
+
+       if (defined $lastid) {
+               if ($t < $lastid) {
+                       my $wt;
+                       if (($wt = $t+86400-$lastid) > $pc9x_past_age) {
+                               print "PCPROT: dup id on $t + 86400 - $lastid ($wt) > $pc9x_past_age, ignored\n";
+                               return;
+                       }
+                       print "wt = $wt ";
+               } elsif ($t == $lastid) {
+                       print "PCPROT: dup id on $t == $lastid, ignored\n";
+                       return;
+               } elsif ($t > $lastid) {
+                       if ($t - $lastid > $pc9x_future_age) {
+                               print "PCPROT: dup id $t too far in future on $lastid\n";
+                               return;
+                       }
+               }
+       }
+
+       print "$lastid Ok\n";
+       $lastid = $t;
+}
+
+