X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FObject-Remote.git;a=blobdiff_plain;f=lib%2FObject%2FRemote%2FReadChannel.pm;h=5de5bf131a6edd0e8a69674b37f263ffc28404f2;hp=84b3270a902fc98709446853a3bb4d2fdbedd82b;hb=5d59cb9859e004df5cde5d83aa7230e621a28b95;hpb=a63cd862186adf328e26dd1294e7a3b1adc42ed6 diff --git a/lib/Object/Remote/ReadChannel.pm b/lib/Object/Remote/ReadChannel.pm index 84b3270..5de5bf1 100644 --- a/lib/Object/Remote/ReadChannel.pm +++ b/lib/Object/Remote/ReadChannel.pm @@ -2,6 +2,7 @@ package Object::Remote::ReadChannel; use CPS::Future; use Scalar::Util qw(weaken); +use Object::Remote::Logging qw(:log); use Moo; has fh => ( @@ -9,6 +10,7 @@ has fh => ( trigger => sub { my ($self, $fh) = @_; weaken($self); + log_trace { "Watching filehandle via trigger on 'fh' attribute in Object::Remote::ReadChannel" }; Object::Remote->current_loop ->watch_io( handle => $fh, @@ -27,14 +29,17 @@ has _receive_data_buffer => (is => 'ro', default => sub { my $x = ''; \$x }); sub _receive_data_from { my ($self, $fh) = @_; + log_trace { "Preparing to read data" }; my $rb = $self->_receive_data_buffer; my $len = sysread($fh, $$rb, 1024, length($$rb)); my $err = defined($len) ? '' : ": $!"; if (defined($len) and $len > 0) { + log_trace { "Read $len bytes of data" }; while (my $cb = $self->on_line_call and $$rb =~ s/^(.*)\n//) { $cb->(my $line = $1); } } else { + log_trace { "Got EOF or error, this read channel is done" }; Object::Remote->current_loop ->unwatch_io( handle => $self->fh, @@ -47,6 +52,7 @@ sub _receive_data_from { sub DEMOLISH { my ($self, $gd) = @_; return if $gd; + log_trace { "read channel is being demolished" }; Object::Remote->current_loop ->unwatch_io( handle => $self->fh,