Changeset: 76662f0c364c for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=76662f0c364c Modified Files: clients/ChangeLog.Aug2011 clients/perl/Mapi.pm Branch: Aug2011 Log Message:
perl: make sure blocks are completely read. Fixed bug 2897 where slow (network) reads could cause blocks to not be fully read in one go, causing errors in the subsequent use of those blocks. diffs (61 lines): diff --git a/clients/ChangeLog.Aug2011 b/clients/ChangeLog.Aug2011 --- a/clients/ChangeLog.Aug2011 +++ b/clients/ChangeLog.Aug2011 @@ -1,6 +1,11 @@ # ChangeLog file for clients # This file is updated with Maddlog +* Fri Oct 7 2011 Sjoerd Mullender <[email protected]> +- Fixed bug 2897 where slow (network) reads could cause blocks to not + be fully read in one go, causing errors in the subsequent use of + those blocks. With thanks to Rémy Chibois. + * Tue Sep 27 2011 Fabian Groffen <[email protected]> - Fixed a bug in mclient where processing queries from files could result in ghost empty results to be reported in the output diff --git a/clients/perl/Mapi.pm b/clients/perl/Mapi.pm --- a/clients/perl/Mapi.pm +++ b/clients/perl/Mapi.pm @@ -375,6 +375,24 @@ sub getReply { } +sub readFromSocket { + my ($self, $ref, $count) = @_; + + die "invalid buffer reference" unless (ref($ref) eq 'SCALAR'); + + my $rcount = 0; + $$ref ||= ""; + + while ($count > 0) { + $rcount = $self->{socket}->sysread($$ref, $count, length($$ref)); + + die "read error: $!" unless (defined($rcount)); + die "no more data on socket" if ($rcount == 0); + + $count -= $rcount; + } +} + sub getblock { my ($self) = @_; @@ -384,7 +402,7 @@ sub getblock { do { my $flag; - $self->{socket}->sysread( $flag, 2 ); # read block info + $self->readFromSocket(\$flag, 2); # read block info my $unpacked = unpack( 'v', $flag ); # unpack (little endian short) my $len = ( $unpacked >> 1 ); # get length @@ -393,7 +411,7 @@ sub getblock { print "getblock: $last_block $len\n" if ($self->{trace}); if ($len > 0 ) { my $data; - $self->{socket}->sysread( $data, $len );# read + $self->readFromSocket(\$data, $len); # read $result .= $data; print "getblock: $data\n" if ($self->{trace}); } _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
