summaryrefslogtreecommitdiff
path: root/src/t_stream.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-11-18 16:13:16 +0800
committerGitHub <noreply@github.com>2021-11-18 10:13:16 +0200
commit91e77a0cfb5c7e4bc6473ae04353e48ad9e8697b (patch)
tree1c97446e9c788eaa0789fa26c645d4523ed0e149 /src/t_stream.c
parent32215e788955acd7845d3839ba1f78e137ca0dfb (diff)
downloadredis-91e77a0cfb5c7e4bc6473ae04353e48ad9e8697b.tar.gz
Fixes ZPOPMIN/ZPOPMAX wrong replies when count is 0 with non-zset (#9711)
Moves ZPOP ... 0 fast exit path after type check to reply with WRONGTYPE. In the past it will return an empty array. Also now count is not allowed to be negative. see #9680 before: ``` 127.0.0.1:6379> set zset str OK 127.0.0.1:6379> zpopmin zset 0 (empty array) 127.0.0.1:6379> zpopmin zset -1 (empty array) ``` after: ``` 127.0.0.1:6379> set zset str OK 127.0.0.1:6379> zpopmin zset 0 (error) WRONGTYPE Operation against a key holding the wrong kind of value 127.0.0.1:6379> zpopmin zset -1 (error) ERR value is out of range, must be positive ```
Diffstat (limited to 'src/t_stream.c')
-rw-r--r--src/t_stream.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_stream.c b/src/t_stream.c
index 900e23d0e..776030c94 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -2182,7 +2182,7 @@ void xreadCommand(client *c) {
goto cleanup;
}
blockForKeys(c, BLOCKED_STREAM, c->argv+streams_arg, streams_count,
- 0, timeout, NULL, NULL, ids);
+ -1, timeout, NULL, NULL, ids);
/* If no COUNT is given and we block, set a relatively small count:
* in case the ID provided is too low, we do not want the server to
* block just to serve this client a huge stream of messages. */