From 6ba50784b5ce2e4eae74da00536ebbc1f81984ae Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 5 Nov 2018 13:16:00 +0100 Subject: [PATCH] Fix XCLAIM missing entry bug. This bug had a double effect: 1. Sometimes entries may not be emitted, producing broken protocol where the array length was greater than the emitted entires, blocking the client waiting for more data. 2. Some other time the right entry was claimed, but a wrong entry was returned to the client. This fix should correct both the instances. --- src/t_stream.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/t_stream.c b/src/t_stream.c index 78f89b7a7..73f7fca0e 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -2278,8 +2278,9 @@ void xclaimCommand(client *c) { if (justid) { addReplyStreamID(c,&id); } else { - streamReplyWithRange(c,o->ptr,&id,NULL,1,0,NULL,NULL, - STREAM_RWR_RAWENTRIES,NULL); + size_t emitted = streamReplyWithRange(c,o->ptr,&id,&id,1,0, + NULL,NULL,STREAM_RWR_RAWENTRIES,NULL); + if (!emitted) addReply(c,shared.nullbulk); } arraylen++;