alter changing %conns callsign logic slightly
[spider.git] / perl / Msg.pm
index 815937963962169d8fb2e4d8e0808cb8675bc2a4..0e6ee9661c07abd36053f5a1ef1032db739f1d43 100644 (file)
@@ -118,7 +118,8 @@ sub conns
        if (ref $pkg) {
                $call = $pkg->{call} unless $call;
                return undef unless $call;
-               confess "changing $pkg->{call} to $call" if exists $pkg->{call} && $call ne $pkg->{call};
+               dbg('connll', "changing $pkg->{call} to $call") if exists $pkg->{call} && $call ne $pkg->{call};
+               delete $conns{$pkg->{call}} if $pkg->{call} ne $call; 
                $pkg->{call} = $call;
                $ref = $conns{$call} = $pkg;
                dbg('connll', "Connection $pkg->{cnum} $call stored");
@@ -134,9 +135,9 @@ sub pid_gone
        my ($pkg, $pid) = @_;
        
        my @pid = grep {$_->{pid} == $pid} values %conns;
-       for (@pid) {
-               &{$_->{eproc}}($_, "$pid has gorn") if exists $_->{eproc};
-               $_->disconnect;
+       foreach my $p (@pid) {
+               &{$p->{eproc}}($p, "$pid has gorn") if exists $p->{eproc};
+               $p->disconnect;
        }
 }
 
@@ -436,8 +437,8 @@ sub close_server
 # close all clients (this is for forking really)
 sub close_all_clients
 {
-       for (values %conns) {
-               $_->disconnect;
+       foreach my $conn (values %conns) {
+               $conn->disconnect;
        }
 }