Skip to content

Commit

Permalink
fix the problem with interrupted recv
Browse files Browse the repository at this point in the history
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
  • Loading branch information
trinitum committed Oct 11, 2012
1 parent d832126 commit c40d703
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/RedisDB.pm
Expand Up @@ -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 '' ) {
Expand Down

0 comments on commit c40d703

Please sign in to comment.