p5-RedisDB / RedisDB

Perl extension to access Redis
22 stars 11 forks source link

Support for interrupted recv on perl before 5.14 #11

Closed trinitum closed 11 years ago

trinitum commented 11 years ago

I found that the following example works as expected on perl 5.14 and above, but fails with perl 5.10 and 5.12:

use 5.010;
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;

On 5.10 I got the following error:

Error reading reply from server:  at /home/zwon/perl5/perlbrew/perls/perl-5.10.1/lib/site_perl/5.10.1/x86_64-linux/RedisDB.pm line 443.
    RedisDB::get_reply('RedisDB=HASH(0x24dd798)') called at /tmp/redis_recv_eintr.pl line 13

After a bit of experimenting I've found that in certain conditions recv if interrupted returns undef as expected, but sets $! to zero instead of EINTR. This appears to be fixed in 5.14.