X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXChannel.pm;h=584a541c1244e44a8b3f1ae90e22b09a8b72e793;hb=a22dbff21bb1ccb696276c23566ba830421fd3a0;hp=8fc86495cc759da969a7ada953963654d016f8e9;hpb=0702d383db04a014535eb7cba323da7e763e219d;p=spider.git diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 8fc86495..584a541c 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -147,11 +147,16 @@ sub alloc { my ($pkg, $call, $conn, $user) = @_; my $self = {}; - + die "trying to create a duplicate channel for $call" if $channels{$call}; + bless $self, $pkg; + $self->{call} = $call; $self->{priv} = 0; - $self->{conn} = $conn if defined $conn; # if this isn't defined then it must be a list + if (defined $conn && ref $conn) { # if this isn't defined then it must be a list + $self->{conn} = $conn; + $conn->set_on_eof(sub {$self->disconnect}); + } if (defined $user) { $self->{user} = $user; $self->{lang} = $user->lang; @@ -177,7 +182,6 @@ sub alloc $count++; dbg("DXChannel $self->{call} created ($count)") if isdbg('chan'); - bless $self, $pkg; return $channels{$call} = $self; } @@ -202,7 +206,9 @@ sub rebless { my $self = shift; my $class = shift; - return $channels{$self->{call}} = bless $self, $class; + my $new = bless $self, $class; + $new->{conn}->on_eof(sub {$new->disconnect}); + return $channels{$self->{call}} = $new; } sub rec