X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FObject%2FRemote%2FReadChannel.pm;h=f6a7cca65c1dada32a5e1a405d979918151b7035;hb=b7a853b30e7397854a813f6a5878e50703a20079;hp=fb13c807d930ca7cb2702b7ecfd8f2963d2551ef;hpb=f8080c1c188fa6c4589ffcad8793e0cf7a8d4bdb;p=scpubgit%2FObject-Remote.git diff --git a/lib/Object/Remote/ReadChannel.pm b/lib/Object/Remote/ReadChannel.pm index fb13c80..f6a7cca 100644 --- a/lib/Object/Remote/ReadChannel.pm +++ b/lib/Object/Remote/ReadChannel.pm @@ -1,7 +1,7 @@ package Object::Remote::ReadChannel; use CPS::Future; -use Scalar::Util qw(weaken); +use Scalar::Util qw(weaken openhandle); use Object::Remote::Logging qw(:log :dlog); use POSIX; use Moo; @@ -33,7 +33,7 @@ sub _receive_data_from { Dlog_trace { "Preparing to read data from $_" } $fh; my $rb = $self->_receive_data_buffer; my $len = sysread($fh, $$rb, 32768, length($$rb)); - my $err = defined($len) ? '' : ": $!"; + my $err = defined($len) ? 'eof' : ": $!"; if (defined($len) and $len > 0) { log_trace { "Read $len bytes of data" }; while (my $cb = $self->on_line_call and $$rb =~ s/^(.*)\n//) { @@ -58,11 +58,14 @@ sub DEMOLISH { my ($self, $gd) = @_; return if $gd; log_trace { "read channel is being demolished" }; + Object::Remote->current_loop ->unwatch_io( handle => $self->fh, on_read_ready => 1 ); + + } 1;