From: minima Date: Sat, 6 Jan 2007 21:50:41 +0000 (+0000) Subject: fix up times and move things around for pc92 X-Git-Tag: 1.54~66 X-Git-Url: http://dxspider.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=db0959118b4c5045e842cf07c399e2924bd6ca10;p=spider.git fix up times and move things around for pc92 --- diff --git a/perl/DXProt.pm b/perl/DXProt.pm index aaa07048..080b421a 100644 --- a/perl/DXProt.pm +++ b/perl/DXProt.pm @@ -32,7 +32,6 @@ use DXHash; use Route; use Route::Node; use Script; -use Investigate; use RouteDB; use DXProtHandle; diff --git a/perl/DXProtHandle.pm b/perl/DXProtHandle.pm index 5d7aee9a..26781885 100644 --- a/perl/DXProtHandle.pm +++ b/perl/DXProtHandle.pm @@ -32,7 +32,6 @@ use DXHash; use Route; use Route::Node; use Script; -use Investigate; use RouteDB; @@ -1332,6 +1331,43 @@ sub _del_thingy return @rout; } +my $_last_time; +my $_last_occurs; + +sub gen_pc9x_t +{ + if (!$_last_time || $_last_time != $main::systime) { + $_last_time = $main::systime; + $_last_occurs = 0; + return $_last_time; + } else { + $_last_occurs++; + return sprintf "$_last_time.%02d", $_last_occurs; + } +} + +sub check_pc9x_t +{ + my $call = shift; + my $t = shift; + my $pc = shift; + my $create = shift; + + my $parent = ref $call ? $call : Route::Node::get($call); + if ($parent) { + my $lastid = $parent->lastid->{$pc} || 0; + if ($lastid >= $t) { + dbg("PCPROT: dup / old id on $call <= $lastid, ignored") if isdbg('chanerr'); + return; + } + } elsif ($create) { + $parent = Route::Node->new($call); + } + $parent->lastid->{$pc} = $t; + + return $parent; +} + # DXSpider routing entries sub handle_92 { @@ -1357,35 +1393,33 @@ sub handle_92 return; } - my $parent = Route::Node::get($pcall); - if ($parent) { - my $lastid = $parent->lastid->{92} || 0; - if ($lastid > $t) { - dbg("PCPROT: dup / old id <= $lastid, ignored") if isdbg('chanerr'); - return; - } - } else { - $parent = Route::Node->new($pcall); - } + my $parent = check_pc9x_t($pcall, $t, 92, 1); + $parent->lastid->{92} = $t; + $parent->do_pc92(1); if (@ent) { + + # look at the first one which will always be a node of some sort + # and update any information that needs to be done. my ($call, $is_node, $is_extnode, $here, $version, $build) = _decode_pc92_call($ent[0]); - if ($call && $is_node && $call eq $pcall) { - $parent->here(Route::here($here)); - $parent->version($version) if $version; - $parent->build($build) if $build; - } elsif ($is_extnode) { - # reparent to external node (note that we must have received a 'C' or 'A' record - # from the true parent node for this external before we get one for the this node - unless ($parent = Route::Node::get($call)) { - dbg("PCPROT: no previous C or A for this external node received, ignored") if isdbg('chanerr'); - return; + if ($call && $is_node) { + if ($is_extnode) { + # reparent to external node (note that we must have received a 'C' or 'A' record + # from the true parent node for this external before we get one for the this node + unless ($parent = Route::Node::get($call)) { + dbg("PCPROT: no previous C or A for this external node received, ignored") if isdbg('chanerr'); + return; + } + my $parent = check_pc9x_t($call, $t, 92) || return; } } else { dbg("PCPROT: must be mycall or external node as first entry, ignored") if isdbg('chanerr'); return; } + $parent->here(Route::here($here)); + $parent->version($version) if $version && $version > $parent->version; + $parent->build($build) if $build && $build > $parent->build; shift @ent; } @@ -1466,3 +1500,5 @@ sub handle_default } } } + +1; diff --git a/perl/DXProtout.pm b/perl/DXProtout.pm index 0ba94dc6..6b06fb13 100644 --- a/perl/DXProtout.pm +++ b/perl/DXProtout.pm @@ -377,27 +377,12 @@ sub pc85 # spider route broadcasts # -my $_last_time; -my $_last_occurs; - -sub _gen_time -{ - if (!$_last_time || $_last_time != $main::systime) { - $_last_time = $main::systime; - $_last_occurs = 0; - return $_last_time; - } else { - $_last_occurs++; - return sprintf "$_last_time.%02d", $_last_occurs; - } -} sub _gen_pc92 { my $sort = shift; -# my $ext = $sort eq 'C'; - my $ext = 1; - my $s = "PC92^$main::mycall^" . _gen_time . "^$sort"; + my $ext = shift; + my $s = "PC92^$main::mycall^" . gen_pc9x_t() . "^$sort"; for (@_) { $s .= "^" . _encode_pc92_call($_, $ext); } @@ -420,19 +405,19 @@ sub gen_pc92_with_time # add a local one sub pc92a { - return _gen_pc92('A', @_); + return _gen_pc92('A', 0, @_); } # delete a local one sub pc92d { - return _gen_pc92('D', @_); + return _gen_pc92('D', 0, @_); } # send a config sub pc92c { - return _gen_pc92('C', @_); + return _gen_pc92('C', 1, @_); } 1; diff --git a/perl/Route/Node.pm b/perl/Route/Node.pm index 67e32a00..d1b0b164 100644 --- a/perl/Route/Node.pm +++ b/perl/Route/Node.pm @@ -32,6 +32,7 @@ use vars qw(%list %valid @ISA $max $filterdef); handle_xml => '0,Using XML,yesno', lastmsg => '0,Last Route Msg,atime', lastid => '0,Last Route MsgID', + do_pc92 => '0,Uses pc92,yesno', ); $filterdef = $Route::filterdef;