From b42466b92586d1adfeec54bda14d4ad54b0764d6 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 19 Nov 2019 11:23:43 +0100 Subject: [PATCH] Fix patch provided in #6554. --- src/blocked.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/blocked.c b/src/blocked.c index dea4cc57..47bb290a 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -514,6 +514,13 @@ void handleClientsBlockedOnKeys(void) { * we can safely call signalKeyAsReady() against this key. */ dictDelete(rl->db->ready_keys,rl->key); + /* Even if we are not inside call(), increment the call depth + * in order to make sure that keys are expired against a fixed + * reference time, and not against the wallclock time. This + * way we can lookup an object multiple times (BRPOPLPUSH does + * that) without the risk of it being freed in the second + * lookup, invalidating the first one. + * See https://github.com/antirez/redis/pull/6554. */ server.call_depth++; updateCachedTime(0); @@ -533,7 +540,7 @@ void handleClientsBlockedOnKeys(void) { serveClientsBlockedOnKeyByModule(rl); } - server.call_depth++; + server.call_depth--; /* Free this item. */ decrRefCount(rl->key);