diff --git a/src/blocked.c b/src/blocked.c index 499b63540..12b1ebdc4 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -262,6 +262,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); @@ -461,7 +468,7 @@ void handleClientsBlockedOnKeys(void) { } } - server.call_depth++; + server.call_depth--; /* Free this item. */ decrRefCount(rl->key);