From c40d7033263880964ddfd0bc50d475545fc78668 Mon Sep 17 00:00:00 2001 From: Pavel Shaydo Date: Thu, 11 Oct 2012 21:36:38 +0800 Subject: [PATCH] fix the problem with interrupted recv in perl before 5.14 if recv was interrupted in certain conditions it sets $! to 0 instead of expected EINTR. The following script demonstrates the issue, it works on 5.14 but fails if run by perl 5.10: use strict; use warnings; use RedisDB 2.07; my $pub = RedisDB->new; my $sub = RedisDB->new; $sub->subscribe('foo'); $sub->get_reply; local $SIG{ALRM} = sub { $pub->publish( 'foo', 'bar' ); }; alarm 2; $sub->get_reply; fixes #11 --- lib/RedisDB.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/RedisDB.pm b/lib/RedisDB.pm index 39f8f40..c585568 100644 --- a/lib/RedisDB.pm +++ b/lib/RedisDB.pm @@ -439,7 +439,7 @@ sub get_reply { while ( not @{ $self->{_replies} } ) { my $ret = $self->{_socket}->recv( my $buffer, 131072 ); unless ( defined $ret ) { - next if $! == EINTR; + next if $! == EINTR or $! == 0; confess "Error reading reply from server: $!"; } if ( $buffer ne '' ) {