diff options
author | Bjorn Svensson <bjorn.a.svensson@est.tech> | 2021-12-22 19:44:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-22 10:44:29 -0800 |
commit | 58aacdac65a04f611e2a659cd60ffa283b8bdf54 (patch) | |
tree | 40e2e95128f4952b1e511fcb7b2324a2532c05c1 /async.c | |
parent | d3384260e7e1726747bd78474e4b0874a4b0a236 (diff) |
Handle array response in parallell with pubsub using RESP3 (#1014)
RESP3 allows sending commands in parallell with pubsub handling
and these commands might get responded with a REDIS_REPLY_ARRAY.
This conflicts with the pubsub response handling for RESP2 and
results in a faulty state when using RESP3.
Add functionality to keep track of PUSH/RESP3 support on the connection
and only expect the message type REDIS_REPLY_PUSH as subscribe messages
when once seen.
Diffstat (limited to 'async.c')
-rw-r--r-- | async.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -420,7 +420,7 @@ static int __redisGetSubscribeCallback(redisAsyncContext *ac, redisReply *reply, /* Match reply with the expected format of a pushed message. * The type and number of elements (3 to 4) are specified at: * https://redis.io/topics/pubsub#format-of-pushed-messages */ - if ((reply->type == REDIS_REPLY_ARRAY && reply->elements >= 3) || + if ((reply->type == REDIS_REPLY_ARRAY && !(c->flags & REDIS_SUPPORTS_PUSH) && reply->elements >= 3) || reply->type == REDIS_REPLY_PUSH) { assert(reply->element[0]->type == REDIS_REPLY_STRING); stype = reply->element[0]->str; @@ -525,6 +525,9 @@ void redisProcessCallbacks(redisAsyncContext *ac) { break; } + /* Keep track of push message support for subscribe handling */ + if (redisIsPushReply(reply)) c->flags |= REDIS_SUPPORTS_PUSH; + /* Send any non-subscribe related PUSH messages to our PUSH handler * while allowing subscribe related PUSH messages to pass through. * This allows existing code to be backward compatible and work in |