Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

&unsubscribe assumes {_psubscribed} is defined #18

Closed
cameronpm opened this issue Mar 7, 2014 · 1 comment
Closed

&unsubscribe assumes {_psubscribed} is defined #18

cameronpm opened this issue Mar 7, 2014 · 1 comment
Labels

Comments

@cameronpm
Copy link

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
Copy link
Member

trinitum commented Mar 9, 2014

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.

@trinitum trinitum added the bug label Mar 10, 2014
trinitum added a commit that referenced this issue Apr 19, 2014
it should be possible to subscribe to some channels first,
and then enter subscription loop. I still need to fix callback
handling before entering subscription loop, currently get_reply
will return message instead of invoking callback. See #18
trinitum added a commit that referenced this issue Apr 19, 2014
now callbacks set with subscribe are expected to be executed
even outside of the subscription loop. See #18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants