From e9ea8ca7cd1261a7c512c555179f7fafc9fe61da Mon Sep 17 00:00:00 2001 From: Ran Shidlansik Date: Fri, 26 Dec 2025 08:25:48 +0200 Subject: [PATCH] Revert "Avoid hgetall deferred response (#2966)" This reverts commit 75707ac4323b30f112e862b734e3436fa03b620c. Signed-off-by: Ran Shidlansik --- src/t_hash.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/t_hash.c b/src/t_hash.c index c0a2bcde9e5..d16157f29f5 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -1613,8 +1613,6 @@ void genericHgetallCommand(client *c, int flags) { hashTypeIterator hi; int count = 0; - void *replylen = NULL; /* In case we use a deferred reply path */ - robj *emptyResp = (flags & OBJ_HASH_FIELD && flags & OBJ_HASH_VALUE) ? shared.emptymap[c->resp] : shared.emptyarray; if ((o = lookupKeyReadOrReply(c, c->argv[1], emptyResp)) == NULL || checkType(c, o, OBJ_HASH)) return; @@ -1622,18 +1620,7 @@ void genericHgetallCommand(client *c, int flags) { if (!wpc) return; /* We return a map if the user requested fields and values, like in the * HGETALL case. Otherwise to use a flat array makes more sense. */ - - if (!hashTypeHasVolatileFields(o)) { - unsigned long length = hashTypeLength(o); - if (flags & OBJ_HASH_FIELD && flags & OBJ_HASH_VALUE) { - addWritePreparedReplyMapLen(wpc, length); - } else { - addWritePreparedReplyArrayLen(wpc, length); - } - } else { - replylen = addReplyDeferredLen(c); - } - + void *replylen = addReplyDeferredLen(c); hashTypeInitIterator(o, &hi); while (hashTypeNext(&hi) != C_ERR) { if (flags & OBJ_HASH_FIELD) { @@ -1647,13 +1634,12 @@ void genericHgetallCommand(client *c, int flags) { } hashTypeResetIterator(&hi); - /* In case of deferred reply, make sure we returned the right number of elements. */ - if (replylen) { - if (flags & OBJ_HASH_FIELD && flags & OBJ_HASH_VALUE) { - setDeferredMapLen(c, replylen, count /= 2); - } else { - setDeferredArrayLen(c, replylen, count); - } + /* Make sure we returned the right number of elements. */ + if (flags & OBJ_HASH_FIELD && flags & OBJ_HASH_VALUE) { + setDeferredMapLen(c, replylen, count /= 2); + count /= 2; + } else { + setDeferredArrayLen(c, replylen, count); } }