p5-RedisDB / RedisDB

Perl extension to access Redis
22 stars 11 forks source link

&unsubscribe assumes {_psubscribed} is defined #18

Closed cameronpm closed 10 years ago

cameronpm commented 10 years ago

I had some code where I needed to subscribe to a channel before I entered the blocking subscription loop. This does not work because you get "Already in subscription loop" as an error message, since {_subscription_loop} is assigned -1 in &subscribe. I don't know if that's a feature or a bug, it was certainly a surprise.

No matter, I attempted this and got this error:

use strict; use warnings;
use RedisDB::Parser v2.20;
use RedisDB v2.29;

my $r = RedisDB->new;

$r->subscribe("foo");
$r->get_reply;
# uncomment for this to work
# $r->{_psubscribed} = {};
$r->unsubscribe("foo"); # this will cause a crash
$r->unsubscribe; # this too will cause a crash
Can't use an undefined value as a HASH reference at /tmp/RedisDB-2.29/blib/lib/RedisDB.pm line 1348.
trinitum commented 10 years ago

Thanks for the report. The first issue is intended behaviour, I will look if it is possible to fix. The second is definitely a bug, I have no time right now, but will release the fix tomorrow.