From 0484dbcf68638149a8510537fd1a42c836f84020 Mon Sep 17 00:00:00 2001 From: "dejun.xdj" Date: Tue, 10 Jul 2018 16:46:48 +0800 Subject: [PATCH 1/3] Streams: using streamCompareID() instead of direct compare. --- src/t_stream.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/t_stream.c b/src/t_stream.c index 54d6b0d1..6a4439d0 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -1392,9 +1392,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; } @@ -1402,9 +1400,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; } } From a2177cd2b6bcbacc376d9640727cd89c5ffed3fa Mon Sep 17 00:00:00 2001 From: "dejun.xdj" Date: Sat, 14 Jul 2018 15:02:24 +0800 Subject: [PATCH 2/3] Streams: add streamCompareID() declaration in stream.h. --- src/stream.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stream.h b/src/stream.h index 61210f95..ef08753b 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 From 491682a668dc5eeffdb6c989b819c1015c97b4f0 Mon Sep 17 00:00:00 2001 From: "dejun.xdj" Date: Sat, 14 Jul 2018 15:03:05 +0800 Subject: [PATCH 3/3] Streams: using streamCompareID() instead of direct compare in block.c. --- src/blocked.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/blocked.c b/src/blocked.c index d8ae596d..4a667501 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 */