Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
a7d89833
Commit
a7d89833
authored
Sep 08, 2017
by
antirez
Browse files
Streams: XREAD get-key method fixed.
parent
11004182
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
a7d89833
...
...
@@ -1364,8 +1364,8 @@ int *georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numk
}
/* XREAD [BLOCK <milliseconds>] [COUNT <count>] [GROUP <groupname> <ttl>]
* [RETRY <milliseconds> <ttl>] STREAMS key_1
ID_1
key_2
ID_2 ...
*
key_N
ID_N */
* [RETRY <milliseconds> <ttl>] STREAMS key_1 key_2
... key_N
*
ID_1 ID_2 ...
ID_N */
int
*
xreadGetKeys
(
struct
redisCommand
*
cmd
,
robj
**
argv
,
int
argc
,
int
*
numkeys
)
{
int
i
,
num
,
*
keys
;
UNUSED
(
cmd
);
...
...
@@ -1377,14 +1377,16 @@ int *xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys)
char
*
arg
=
argv
[
i
]
->
ptr
;
if
(
!
strcasecmp
(
arg
,
"streams"
))
streams_pos
=
i
;
}
if
(
streams_pos
!=
-
1
)
num
=
argc
-
streams_pos
-
1
;
/* Syntax error. */
if
(
streams_pos
==
-
1
)
{
if
(
streams_pos
==
-
1
||
num
%
2
!=
0
)
{
*
numkeys
=
0
;
return
NULL
;
}
num
/=
2
;
/* We have half the keys as there are arguments because
there are also the IDs, one per key. */
num
=
argc
-
streams_pos
-
1
;
keys
=
zmalloc
(
sizeof
(
int
)
*
num
);
for
(
i
=
streams_pos
+
1
;
i
<
argc
;
i
++
)
keys
[
i
-
streams_pos
-
1
]
=
i
;
*
numkeys
=
num
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment