[Sprog-commit] SF.net SVN: sprog:[798] modules/sprog/trunk/lib/Sprog
Status: Alpha
Brought to you by:
grantm
|
From: <gr...@us...> - 2008-09-20 23:03:19
|
Revision: 798
http://sprog.svn.sourceforge.net/sprog/?rev=798&view=rev
Author: grantm
Date: 2008-09-20 23:03:11 +0000 (Sat, 20 Sep 2008)
Log Message:
-----------
fix for buffering problem reading from filehandle
Modified Paths:
--------------
modules/sprog/trunk/lib/Sprog/GlibEventLoop.pm
modules/sprog/trunk/lib/Sprog/Mixin/InputFromFH.pm
Modified: modules/sprog/trunk/lib/Sprog/GlibEventLoop.pm
===================================================================
--- modules/sprog/trunk/lib/Sprog/GlibEventLoop.pm 2008-08-21 10:11:19 UTC (rev 797)
+++ modules/sprog/trunk/lib/Sprog/GlibEventLoop.pm 2008-09-20 23:03:11 UTC (rev 798)
@@ -2,6 +2,7 @@
use Glib ();
+use IO::Handle ();
my $loop;
@@ -28,6 +29,7 @@
sub add_io_reader {
my($class, $fh, $sub) = @_;
+ $fh->blocking(0);
return Glib::IO->add_watch(fileno($fh), ['in', 'err', 'hup'], $sub);
}
@@ -35,6 +37,7 @@
sub add_io_writer {
my($class, $fh, $sub) = @_;
+ $fh->blocking(0);
return Glib::IO->add_watch(fileno($fh), ['out', 'err', 'hup'], $sub);
}
Modified: modules/sprog/trunk/lib/Sprog/Mixin/InputFromFH.pm
===================================================================
--- modules/sprog/trunk/lib/Sprog/Mixin/InputFromFH.pm 2008-08-21 10:11:19 UTC (rev 797)
+++ modules/sprog/trunk/lib/Sprog/Mixin/InputFromFH.pm 2008-09-20 23:03:11 UTC (rev 798)
@@ -25,11 +25,11 @@
delete $self->{in_tag};
my $buf;
my $fh = $self->fh_in;
- if(sysread($fh, $buf, BUF_SIZE)) {
+ while(sysread($fh, $buf, BUF_SIZE)) {
$DBG && $DBG->(ref($self) . ' read ' . length($buf) . ' bytes');
$self->msg_out(data => $buf);
}
- else {
+ if(eof($fh)) {
$DBG && $DBG->(ref($self) . ' EOF');
close($fh) if $fh;
$self->fh_in(undef);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|