Fix issue with sync API not advancing. (#2603)

Issue: During conversation, under some conditions, sync cookie is not advanced, and, as a result, client loops on the same sync API call creating high traffic and CPU load.
Fix: pdu component of cookie was updated incorrectly.
This commit is contained in:
sergekh2 2022-08-02 01:43:48 -07:00 committed by GitHub
parent 3d51624fef
commit 6b6b420b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -261,9 +261,9 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse(
var pos types.StreamPosition
if _, pos, err = p.DB.PositionInTopology(ctx, mostRecentEventID); err == nil {
switch {
case r.Backwards && pos > latestPosition:
case r.Backwards && pos < latestPosition:
fallthrough
case !r.Backwards && pos < latestPosition:
case !r.Backwards && pos > latestPosition:
latestPosition = pos
}
}