fix disconnect from peer
authorDirk Koopman <djk@tobit.co.uk>
Fri, 23 Dec 2011 11:23:15 +0000 (11:23 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Fri, 23 Dec 2011 11:23:15 +0000 (11:23 +0000)
perl/DXChannel.pm
perl/Msg.pm
perl/Version.pm

index 8fc86495cc759da969a7ada953963654d016f8e9..584a541c1244e44a8b3f1ae90e22b09a8b72e793 100644 (file)
@@ -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        
index 352904102e32cf35d183ffcd1395e42f5c9c87a0..60906c5964df83b0e547cd28628caaafefdf149c 100644 (file)
@@ -61,11 +61,12 @@ sub set_error
        $conn->{eproc} = $callback;
 }
 
-sub set_eof
+sub set_on_eof
 {
        my $conn = shift;
        my $callback = shift;
-       $conn->{sock}->on_eof(sub {$callback});
+       $conn->{sock}->on_eof($callback);
+       $conn->{sock}->on_error($callback);
 }
 
 sub set_rproc
index fea0581e2083cd1e9a25092e9fb56f72c0b6d6ad..99b2e673ff704ff9fb5f1e01abf144015835e94e 100644 (file)
@@ -11,7 +11,7 @@ use vars qw($version $subversion $build $gitversion);
 
 $version = '1.56';
 $subversion = '0';
-$build = '7';
-$gitversion = 'a60f14f';
+$build = '8';
+$gitversion = '0702d38';
 
 1;