From b8913ce72141237570ddfa07a1e412a03d714c51 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Mon, 11 Jun 2018 01:17:52 +0800 Subject: [PATCH] Streams: checkType for xread & xinfo --- src/t_stream.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/t_stream.c b/src/t_stream.c index 075386dd..6ef1ce51 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -1310,14 +1310,13 @@ void xreadCommand(client *c) { * starting from now. */ int id_idx = i - streams_arg - streams_count; robj *key = c->argv[i-streams_count]; - robj *o; + robj *o = lookupKeyRead(c->db,key); + if (o && checkType(c,o,OBJ_STREAM)) goto cleanup; streamCG *group = NULL; /* If a group was specified, than we need to be sure that the * key and group actually exist. */ if (groupname) { - o = lookupKeyRead(c->db,key); - if (o && checkType(c,o,OBJ_STREAM)) goto cleanup; if (o == NULL || (group = streamLookupCG(o->ptr,groupname->ptr)) == NULL) { @@ -1331,8 +1330,6 @@ void xreadCommand(client *c) { } if (strcmp(c->argv[i]->ptr,"$") == 0) { - o = lookupKeyRead(c->db,key); - if (o && checkType(c,o,OBJ_STREAM)) goto cleanup; if (o) { stream *s = o->ptr; ids[id_idx] = s->last_id; @@ -2179,7 +2176,7 @@ NULL /* Lookup the key now, this is common for all the subcommands but HELP. */ robj *o = lookupKeyWriteOrReply(c,key,shared.nokeyerr); - if (o == NULL) return; + if (o == NULL || checkType(c,o,OBJ_STREAM)) return; s = o->ptr; /* Dispatch the different subcommands. */