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. --- async.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'async.h') diff --git a/async.h b/async.h index 4c65203..41951d4 100644 --- a/async.h +++ b/async.h @@ -46,6 +46,7 @@ typedef struct redisCallback { struct redisCallback *next; /* simple singly linked list */ redisCallbackFn *fn; int pending_subs; + int unsubscribe_sent; void *privdata; } redisCallback; @@ -105,6 +106,7 @@ typedef struct redisAsyncContext { redisCallbackList replies; struct dict *channels; struct dict *patterns; + int pending_unsubs; } sub; /* Any configured RESP3 PUSH handler */ -- cgit v1.2.3