Actually return a response with timeout=0

This commit is contained in:
Kegan Dougal 2022-05-18 19:22:54 +01:00
parent 30fc50d099
commit 0cb04005db

View file

@ -381,11 +381,14 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
// they weren't always doing, resulting in flakey tests. // they weren't always doing, resulting in flakey tests.
if !syncReq.Response.HasUpdates() { if !syncReq.Response.HasUpdates() {
syncReq.Since = currentPos syncReq.Since = currentPos
syncReq.Timeout = syncReq.Timeout - time.Since(startTime) // do not loop again if the ?timeout= is 0 as that means "return immediately"
if syncReq.Timeout < 0 { if syncReq.Timeout > 0 {
syncReq.Timeout = 0 syncReq.Timeout = syncReq.Timeout - time.Since(startTime)
if syncReq.Timeout < 0 {
syncReq.Timeout = 0
}
continue
} }
continue
} }
} }