mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Merge pull request #5113 from 0xtonyxia/using-compare-func-instead
Streams: using streamCompareID() instead of direct compare.
This commit is contained in:
commit
9fbd49bbaf
@ -397,10 +397,7 @@ void handleClientsBlockedOnKeys(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->last_id.ms > gt->ms ||
|
if (streamCompareID(&s->last_id, gt) > 0) {
|
||||||
(s->last_id.ms == gt->ms &&
|
|
||||||
s->last_id.seq > gt->seq))
|
|
||||||
{
|
|
||||||
streamID start = *gt;
|
streamID start = *gt;
|
||||||
start.seq++; /* Can't overflow, it's an uint64_t */
|
start.seq++; /* Can't overflow, it's an uint64_t */
|
||||||
|
|
||||||
|
@ -108,5 +108,6 @@ streamConsumer *streamLookupConsumer(streamCG *cg, sds name, int create);
|
|||||||
streamCG *streamCreateCG(stream *s, char *name, size_t namelen, streamID *id);
|
streamCG *streamCreateCG(stream *s, char *name, size_t namelen, streamID *id);
|
||||||
streamNACK *streamCreateNACK(streamConsumer *consumer);
|
streamNACK *streamCreateNACK(streamConsumer *consumer);
|
||||||
void streamDecodeID(void *buf, streamID *id);
|
void streamDecodeID(void *buf, streamID *id);
|
||||||
|
int streamCompareID(streamID *a, streamID *b);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1401,9 +1401,7 @@ void xreadCommand(client *c) {
|
|||||||
* synchronously in case the group top item delivered is smaller
|
* synchronously in case the group top item delivered is smaller
|
||||||
* than what the stream has inside. */
|
* than what the stream has inside. */
|
||||||
streamID *last = &groups[i]->last_id;
|
streamID *last = &groups[i]->last_id;
|
||||||
if (s->last_id.ms > last->ms ||
|
if (streamCompareID(&s->last_id, last) > 0) {
|
||||||
(s->last_id.ms == last->ms && s->last_id.seq > last->seq))
|
|
||||||
{
|
|
||||||
serve_synchronously = 1;
|
serve_synchronously = 1;
|
||||||
*gt = *last;
|
*gt = *last;
|
||||||
}
|
}
|
||||||
@ -1411,9 +1409,7 @@ void xreadCommand(client *c) {
|
|||||||
} else {
|
} else {
|
||||||
/* For consumers without a group, we serve synchronously if we can
|
/* For consumers without a group, we serve synchronously if we can
|
||||||
* actually provide at least one item from the stream. */
|
* actually provide at least one item from the stream. */
|
||||||
if (s->last_id.ms > gt->ms ||
|
if (streamCompareID(&s->last_id, gt) > 0) {
|
||||||
(s->last_id.ms == gt->ms && s->last_id.seq > gt->seq))
|
|
||||||
{
|
|
||||||
serve_synchronously = 1;
|
serve_synchronously = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user