diff options
author | Viktor Söderqvist <viktor.soderqvist@est.tech> | 2021-01-19 12:15:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 13:15:33 +0200 |
commit | 4985c11bd6ef67a8eb58716f6c2b6b3d96e8538e (patch) | |
tree | 6dc3d0e5d22d79311bfb5f240c1b54180f6f467e /src | |
parent | 5198b513d3001fb6399823909cac90ef8c3381e8 (diff) | |
download | redis-4985c11bd6ef67a8eb58716f6c2b6b3d96e8538e.tar.gz |
Bugfix: Make modules blocked on keys unblock on commands like LPUSH (#8356)
This was a regression from #7625 (only in 6.2 RC2).
This makes it possible again to implement blocking list and zset
commands using the modules API.
This commit also includes a test case for the reverse: A module
unblocks a client blocked on BLPOP by inserting elements using
RedisModule_ListPush(). This already works, but it was untested.
Diffstat (limited to 'src')
-rw-r--r-- | src/blocked.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/blocked.c b/src/blocked.c index 46935c79f..1d69ff902 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -684,10 +684,20 @@ static int getBlockedTypeByType(int type) { void signalKeyAsReady(redisDb *db, robj *key, int type) { readyList *rl; - /* If no clients are blocked on this type, just return */ + /* Quick returns. */ int btype = getBlockedTypeByType(type); - if (btype == BLOCKED_NONE || !server.blocked_clients_by_type[btype]) + if (btype == BLOCKED_NONE) { + /* The type can never block. */ return; + } + if (!server.blocked_clients_by_type[btype] && + !server.blocked_clients_by_type[BLOCKED_MODULE]) { + /* No clients block on this type. Note: Blocked modules are represented + * by BLOCKED_MODULE, even if the intention is to wake up by normal + * types (list, zset, stream), so we need to check that there are no + * blocked modules before we do a quick return here. */ + return; + } /* No clients blocking for this key? No need to queue it. */ if (dictFind(db->blocking_keys,key) == NULL) return; |