From 7123b87f6d237e0ddf75c9698b2961e2d102a69d Mon Sep 17 00:00:00 2001 From: Björn Svensson Date: Wed, 2 Feb 2022 23:29:59 +0100 Subject: 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. --- test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test.c') diff --git a/test.c b/test.c index b76b49a..f43bc24 100644 --- a/test.c +++ b/test.c @@ -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 */ -- cgit v1.2.3