mirror of
https://github.com/fluencelabs/redis
synced 2025-03-26 12:21:04 +00:00
Streams: fix reverse iterator discarding of items out of range.
This commit is contained in:
parent
6919280cc5
commit
9dc79c039a
@ -597,11 +597,18 @@ int streamIteratorGetID(streamIterator *si, streamID *id, int64_t *numfields) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we do not emit, we have to discard. */
|
/* If we do not emit, we have to discard if we are going
|
||||||
int to_discard = (flags & STREAM_ITEM_FLAG_SAMEFIELDS) ?
|
* forward, or seek the previous entry if we are going
|
||||||
*numfields : *numfields*2;
|
* backward. */
|
||||||
for (int64_t i = 0; i < to_discard; i++)
|
if (!si->rev) {
|
||||||
si->lp_ele = lpNext(si->lp,si->lp_ele);
|
int to_discard = (flags & STREAM_ITEM_FLAG_SAMEFIELDS) ?
|
||||||
|
*numfields : *numfields*2;
|
||||||
|
for (int64_t i = 0; i < to_discard; i++)
|
||||||
|
si->lp_ele = lpNext(si->lp,si->lp_ele);
|
||||||
|
} else {
|
||||||
|
int prev_times = 4; /* flag + id ms/seq diff + numfields. */
|
||||||
|
while(prev_times--) si->lp_ele = lpPrev(si->lp,si->lp_ele);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of listpack reached. Try the next/prev radix tree node. */
|
/* End of listpack reached. Try the next/prev radix tree node. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user