summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2018-07-16 18:34:35 +0200
committerGitHub <noreply@github.com>2018-07-16 18:34:35 +0200
commit9fbd49bbaf390c1713353fcb462ef436e2d52547 (patch)
tree83970ef3179409873bf8cc92eb65dd5b1bf38f9b
parentcab396761e6d7dbec99627ac4fa1c441027d56d3 (diff)
parent491682a668dc5eeffdb6c989b819c1015c97b4f0 (diff)
downloadredis-9fbd49bbaf390c1713353fcb462ef436e2d52547.tar.gz
Merge pull request #5113 from 0xtonyxia/using-compare-func-instead
Streams: using streamCompareID() instead of direct compare.
-rw-r--r--src/blocked.c5
-rw-r--r--src/stream.h1
-rw-r--r--src/t_stream.c8
3 files changed, 4 insertions, 10 deletions
diff --git a/src/blocked.c b/src/blocked.c
index d8ae596d9..4a667501f 100644
--- a/src/blocked.c
+++ b/src/blocked.c
@@ -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 */
diff --git a/src/stream.h b/src/stream.h
index 61210f952..ef08753b5 100644
--- a/src/stream.h
+++ b/src/stream.h
@@ -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
diff --git a/src/t_stream.c b/src/t_stream.c
index 3b4ebea78..7b1076b16 100644
--- a/src/t_stream.c
+++ b/src/t_stream.c
@@ -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;
}
}