fix Route::findroutes?
[spider.git] / perl / Route.pm
index 1106892a167c8641147ac76fa02d9118a13057eb..860c5235176449a59a8842b798785a16d8c47ae4 100644 (file)
@@ -298,16 +298,19 @@ sub findroutes
        return () if $seen->{$call};
        if (my $dxchan = DXChannel::get($call)) {
                $seen->{$call}++;
-               push @out, [$level, $dxchan];
+               push @out, $level ? [$level, $dxchan] : $dxchan;
                return @out;
        }
+       $seen->{$call}++;
 
        # deal with more nodes
-       my $nref = Route::Node::get($call);
-       foreach my $ncall (@{$nref->{nodes}}) {
-               dbg("recursing from $call -> $ncall") if isdbg('routec');
-               my @rout = findroute($ncall, $level+1, $seen);
-               push @out, @rout;
+       my $nref = Route::get($call);
+       foreach my $ncall (@{$nref->{parent}}) {
+               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;