diff options
author | Björn Svensson <bjorn.a.svensson@est.tech> | 2022-02-02 23:29:59 +0100 |
---|---|---|
committer | Björn Svensson <bjorn.a.svensson@est.tech> | 2022-02-03 09:26:01 +0100 |
commit | 7123b87f6d237e0ddf75c9698b2961e2d102a69d (patch) | |
tree | 066e4aaf23344cd85c25f7801384b2b30102e8eb /test.c | |
parent | b6fb548fc65497ce933cfd15b6fd91c700d4b34e (diff) |
Handle any pipelined unsubscribe in async
Redis responds to an unsubscribe with one or many replies, depending
on the current subscribe state. When channels/patterns names are
provided in a command each given name will trigger a reply even if
duplicated or not subscribed to.
To know when we can return from the subscribed state we need to do
bookkeeping on pending additional unsubscribe replies, and make sure
we receive them all before switching state.
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1729,10 +1729,10 @@ void subscribe_channel_a_cb(redisAsyncContext *ac, void *r, void *privdata) { strcmp(reply->element[2]->str,"Hello!") == 0); state->checkpoint++; - /* Unsubscribe to channels, including a channel X which we don't subscribe to */ + /* Unsubscribe to channels, including channel X & Z which we don't subscribe to */ redisAsyncCommand(ac,unexpected_cb, (void*)"unsubscribe should not call unexpected_cb()", - "unsubscribe B X A"); + "unsubscribe B X A A Z"); /* Unsubscribe to patterns, none which we subscribe to */ redisAsyncCommand(ac,unexpected_cb, (void*)"punsubscribe should not call unexpected_cb()", @@ -1771,8 +1771,8 @@ void subscribe_channel_b_cb(redisAsyncContext *ac, void *r, void *privdata) { /* Test handling of multiple channels * - subscribe to channel A and B - * - a published message on A triggers an unsubscribe of channel B, X and A - * where channel X is not subscribed to. + * - a published message on A triggers an unsubscribe of channel B, X, A and Z + * where channel X and Z are not subscribed to. * - the published message also triggers an unsubscribe to patterns. Since no * pattern is subscribed to the responded pattern element type is NIL. * - a command sent after unsubscribe triggers a disconnect */ |