X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FRoute.pm;h=72bb5db44b8afb42b7c3319dabfd41ab21b9430d;hb=9392cc93cca60220a2c8e390e716cddc2807f177;hp=d4fb95d4205eae5143959c9c6efd130b0da1eb43;hpb=99e970eab7e843c6810039bc85f462b270534a62;p=spider.git diff --git a/perl/Route.pm b/perl/Route.pm index d4fb95d4..72bb5db4 100644 --- a/perl/Route.pm +++ b/perl/Route.pm @@ -301,13 +301,16 @@ sub findroutes push @out, $level ? [$level, $dxchan] : $dxchan; return @out; } + $seen->{$call}++; # deal with more nodes my $nref = Route::get($call); foreach my $ncall (@{$nref->{parent}}) { - dbg("recursing from $call -> $ncall") if isdbg('routec'); - my @rout = findroutes($ncall, $level+1, $seen); - push @out, @rout; + unless ($seen->{$ncall}) { + dbg("recursing from $call -> $ncall") if isdbg('routec'); + my @rout = findroutes($ncall, $level+1, $seen); + push @out, @rout; + } } return $level == 0 ? map {$_->[1]} sort {$a->[0] <=> $b->[0]} @out : @out; @@ -317,30 +320,7 @@ sub findroutes sub alldxchan { my $self = shift; - my @dxchan; -# dbg("Trying node $self->{call}") if isdbg('routech'); - - my $dxchan = DXChannel::get($self->{call}); - push @dxchan, $dxchan if $dxchan; - - # it isn't, build up a list of dxchannels and possible ping times - # for all the candidates. - unless (@dxchan) { - foreach my $p (@{$self->{parent}}) { -# dbg("Trying parent $p") if isdbg('routech'); - next if $p eq $main::mycall; # the root - my $dxchan = DXChannel::get($p); - if ($dxchan) { - push @dxchan, $dxchan unless grep $dxchan == $_, @dxchan; - } else { - next if grep $p eq $_, @_; - my $ref = Route::Node::get($p); -# dbg("Next node $p " . ($ref ? 'Found' : 'NOT Found') if isdbg('routech') ); - push @dxchan, $ref->alldxchan($self->{call}, @_) if $ref; - } - } - } -# dbg('routech', "Got dxchan: " . join(',', (map{ $_->call } @dxchan)) ); + my @dxchan = findroutes($self->{call}); return @dxchan; } @@ -356,16 +336,18 @@ sub dxchan return undef unless @dxchan; # determine the minimum ping channel - my $minping = 99999999; - foreach my $dxc (@dxchan) { - my $p = $dxc->pingave; - if (defined $p && $p < $minping) { - $minping = $p; - $dxchan = $dxc; - } - } - $dxchan = shift @dxchan unless $dxchan; - return $dxchan; +# my $minping = 99999999; +# foreach my $dxc (@dxchan) { +# my $p = $dxc->pingave; +# if (defined $p && $p < $minping) { +# $minping = $p; +# $dxchan = $dxc; +# } +# } +# $dxchan = shift @dxchan unless $dxchan; + + # dxchannels are now returned in order of "closeness" + return $dxchan[0]; }