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=2d3da400ca516e52e8f282efdadda3d32aaf4533;hp=6402bdd9011b530c40bc653e86b89ff0043fc1cb;hb=901159798e5541050b7c3357a7148818610a4019;hpb=9d64d2d9b2401f99b747ecf754384adb661f0a5b diff --git a/lib/Object/Remote/ReadChannel.pm b/lib/Object/Remote/ReadChannel.pm index 6402bdd..2d3da40 100644 --- a/lib/Object/Remote/ReadChannel.pm +++ b/lib/Object/Remote/ReadChannel.pm @@ -2,7 +2,8 @@ package Object::Remote::ReadChannel; use CPS::Future; use Scalar::Util qw(weaken); -use Object::Remote::Logging qw(:log); +use Object::Remote::Logging qw(:log :dlog); +use POSIX; use Moo; has fh => ( @@ -38,21 +39,23 @@ has _receive_data_buffer => (is => 'ro', default => sub { my $x = ''; \$x }); #there is no actual data to read from the socket sub _receive_data_from { my ($self, $fh) = @_; - log_trace { "Preparing to read data" }; + Dlog_trace { "Preparing to read data from $_" } $fh; #use Carp qw(cluck); cluck(); my $rb = $self->_receive_data_buffer; #TODO is there a specific reason sysread() and syswrite() aren't #a part of ::MiniLoop? It's one spot to handle errors and other #logic involving filehandles - #TODO why are the buffers so small? BUFSIZ is usually 32768 - my $len = sysread($fh, $$rb, 1024, length($$rb)); + my $len = sysread($fh, $$rb, 32768, 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 { + #TODO this isn't compatible with Windows but would be if + #EAGAIN was set to something that could never match + #if on Windows + } elsif ($! != EAGAIN) { log_trace { "Got EOF or error, this read channel is done" }; Object::Remote->current_loop ->unwatch_io(