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
9fbd49bb
Unverified
Commit
9fbd49bb
authored
Jul 16, 2018
by
Salvatore Sanfilippo
Committed by
GitHub
Jul 16, 2018
Browse files
Merge pull request #5113 from 0xtonyxia/using-compare-func-instead
Streams: using streamCompareID() instead of direct compare.
parents
cab39676
491682a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/blocked.c
View file @
9fbd49bb
...
...
@@ -397,10 +397,7 @@ void handleClientsBlockedOnKeys(void) {
}
}
if
(
s
->
last_id
.
ms
>
gt
->
ms
||
(
s
->
last_id
.
ms
==
gt
->
ms
&&
s
->
last_id
.
seq
>
gt
->
seq
))
{
if
(
streamCompareID
(
&
s
->
last_id
,
gt
)
>
0
)
{
streamID
start
=
*
gt
;
start
.
seq
++
;
/* Can't overflow, it's an uint64_t */
...
...
src/stream.h
View file @
9fbd49bb
...
...
@@ -108,5 +108,6 @@ streamConsumer *streamLookupConsumer(streamCG *cg, sds name, int create);
streamCG
*
streamCreateCG
(
stream
*
s
,
char
*
name
,
size_t
namelen
,
streamID
*
id
);
streamNACK
*
streamCreateNACK
(
streamConsumer
*
consumer
);
void
streamDecodeID
(
void
*
buf
,
streamID
*
id
);
int
streamCompareID
(
streamID
*
a
,
streamID
*
b
);
#endif
src/t_stream.c
View file @
9fbd49bb
...
...
@@ -1401,9 +1401,7 @@ void xreadCommand(client *c) {
* synchronously in case the group top item delivered is smaller
* than what the stream has inside. */
streamID
*
last
=
&
groups
[
i
]
->
last_id
;
if
(
s
->
last_id
.
ms
>
last
->
ms
||
(
s
->
last_id
.
ms
==
last
->
ms
&&
s
->
last_id
.
seq
>
last
->
seq
))
{
if
(
streamCompareID
(
&
s
->
last_id
,
last
)
>
0
)
{
serve_synchronously
=
1
;
*
gt
=
*
last
;
}
...
...
@@ -1411,9 +1409,7 @@ void xreadCommand(client *c) {
}
else
{
/* For consumers without a group, we serve synchronously if we can
* actually provide at least one item from the stream. */
if
(
s
->
last_id
.
ms
>
gt
->
ms
||
(
s
->
last_id
.
ms
==
gt
->
ms
&&
s
->
last_id
.
seq
>
gt
->
seq
))
{
if
(
streamCompareID
(
&
s
->
last_id
,
gt
)
>
0
)
{
serve_synchronously
=
1
;
}
}
...
...
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