allow sh/qrz to use a http proxy
[spider.git] / perl / Route / Node.pm
index 3e0c3b0888c6b2305dbc4f4616cf0e5dbb4fcec8..51ecedea2bb6575c9d58220cba96011e696cd9e4 100644 (file)
@@ -83,19 +83,35 @@ sub del
 
        # delete parent from this call's parent list
        my $pcall = $pref->{call};
+       my $ncall = $self->{call};
+       $pref->_delnode($ncall);;
        my $ref = $self->_delparent($pcall);
        my @nodes;
        
-       # is this the last connection?
-       $self->_del_users;
+       # is this the last connection, I have no parents anymore?
        unless (@$ref) {
-               push @nodes, $self->del_nodes;
+               foreach my $rcall (@{$self->{nodes}}) {
+                       next if grep $rcall eq $_, @_;
+                       my $r = Route::Node::get($rcall);
+                       push @nodes, $r->del($self, $ncall, @_) if $r;
+               }
+               $self->_del_users;
                delete $list{$self->{call}};
                push @nodes, $self;
        }
        return @nodes;
 }
 
+sub del_nodes
+{
+       my $parent = shift;
+       my @out;
+       foreach my $rcall (@{$parent->{nodes}}) {
+               my $r = get($rcall);
+               push @out, $r->del($parent, $parent->{call}, @_) if $r;
+       }
+       return @out;
+}
 
 sub _del_users
 {
@@ -107,41 +123,14 @@ sub _del_users
        $self->{users} = [];
 }
 
-# remove all sub nodes from this parent
-sub del_nodes
-{
-       my $self = shift;
-       my @nodes;
-       
-       for (@{$self->{nodes}}) {
-               next if $self->{call} eq $_;
-               push @nodes, $self->del_node($_);
-       }
-       return @nodes;
-}
-
-# delete a node from this node (ie I am a parent) 
-sub del_node
-{
-       my $self = shift;
-       my $ncall = shift;
-       my @out;
-    $self->_delnode($ncall);
-       if (my $ref = get($ncall)) {
-               foreach my $rcall (@{$ref->{nodes}}) {
-                       next if $rcall eq $ncall || $rcall eq $self->{call};
-                       push @out, $ref->del_node($rcall);
-               }
-               push @out, $ref->del($self);
-       }
-       return @out;
-}
-
 # add a user to this node
 sub add_user
 {
        my $self = shift;
        my $ucall = shift;
+
+       confess "Trying to add NULL User call to routing tables" unless $ucall;
+
        $self->_adduser($ucall);
 
        $self->{usercount} = scalar @{$self->{users}};
@@ -190,7 +179,7 @@ sub rnodes
                next if grep $call eq $_, @_;
                push @out, $call;
                my $r = get($call);
-               push @out, $r->rnodes(@_, @out) if $r;
+               push @out, $r->rnodes($call, @_) if $r;
        }
        return @out;
 }
@@ -220,7 +209,7 @@ sub get
        my $call = shift;
        $call = shift if ref $call;
        my $ref = $list{uc $call};
-       dbg('routerr', "Failed to get Node $call" ) unless $ref;
+       dbg("Failed to get Node $call" ) if !$ref && isdbg('routerr');
        return $ref;
 }
 
@@ -273,7 +262,7 @@ sub DESTROY
        my $pkg = ref $self;
        my $call = $self->{call} || "Unknown";
        
-       dbg('route', "destroying $pkg with $call");
+       dbg("destroying $pkg with $call") if isdbg('routelow');
 }
 
 #