-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Assertion `(c->flags & REDIS_SUBSCRIBED || c->flags & REDIS_MONITORING)' fails when calling "SUBSCRIBE aaa" and then "UNSUBSCRIBE aaa bbb" #1039
Comments
|
In this case Redis will reply for each channel given in the unsubscribe command, even if a channel has not been subscribed to. |
Today there is a check in Any thoughts @michael-grunder ? |
Yeah I think it's better to filtering out unknown channels, because sending the test case of |
Hiredis crashes after calling
redisAsyncCommand(c, NULL, NULL, "subscribe aaa")
and thenredisAsyncCommand(c, NULL, NULL, "unsubscribe aaa bbb")
.The code is simply modified from the example "examples/example-ae.c". I compiled the code like this:
AE_DIR=~/redis/src make hiredis-example-ae -j16
:After starting a redis-server on localhost:6379 and run the code, it gave the error below: hiredis-example-ae: async.c:567: redisProcessCallbacks: Assertion `(c->flags & REDIS_SUBSCRIBED || c->flags & REDIS_MONITORING)' failed.
I looked into the codebase of Hiredis and found some possible problem in async.c: in
redisProcessCallbacks
, the function uses a loopwhile((status = redisGetReply(c,&reply)) == REDIS_OK)
to get the reply of commands. For example, after processingSUBSCRIBE aaa
, theredisProcessCallbacks
function is now getting the reply ofUNSUBSCRIBE aaa bbb
. When the reply ofUNSUBSCRIBE aaa
arrives, all channels has already been deleted in__redisGetSubscribeCallback
and thenc->flags &= ~REDIS_SUBSCRIBED
. Then whenredisProcessCallbacks
processUNSUBSCRIBE bbb
's reply, the assertionassert((c->flags & REDIS_SUBSCRIBED || c->flags & REDIS_MONITORING))
fails.The text was updated successfully, but these errors were encountered: