summaryrefslogtreecommitdiff
path: root/src/t_stream.c
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2020-04-02 11:23:23 +0200
committerGitHub <noreply@github.com>2020-04-02 11:23:23 +0200
commitdfef4074999d2640f0336551937605802299f08b (patch)
treeb713a1395e7c0de05fa5b8a6092f03985662c87f /src/t_stream.c
parent8d6dc136e162004b874ffa868246dde7d89d447e (diff)
parent1547d72cf3ec4ef5b67cbba7cf50726983be31e4 (diff)
downloadredis-dfef4074999d2640f0336551937605802299f08b.tar.gz
Merge pull request #7029 from valentinogeron/fix-xack
XACK should be executed in a "all or nothing" fashion.
Diffstat (limited to 'src/t_stream.c')
-rw-r--r--src/t_stream.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 00d1cbf1c..3f8cbfcfa 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -1922,11 +1922,21 @@ void xackCommand(client *c) {
return;
}
+ /* Start parsing the IDs, so that we abort ASAP if there is a syntax
+ * error: the return value of this command cannot be an error in case
+ * the client successfully acknowledged some messages, so it should be
+ * executed in a "all or nothing" fashion. */
+ for (int j = 3; j < c->argc; j++) {
+ streamID id;
+ if (streamParseStrictIDOrReply(c,c->argv[j],&id,0) != C_OK) return;
+ }
+
int acknowledged = 0;
for (int j = 3; j < c->argc; j++) {
streamID id;
unsigned char buf[sizeof(streamID)];
- if (streamParseStrictIDOrReply(c,c->argv[j],&id,0) != C_OK) return;
+ if (streamParseStrictIDOrReply(c,c->argv[j],&id,0) != C_OK)
+ serverPanic("StreamID invalid after check. Should not be possible.");
streamEncodeID(buf,&id);
/* Lookup the ID in the group PEL: it will have a reference to the