From 0cb04005dbf14724309c052cbf8f7e226498dac9 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 18 May 2022 19:22:54 +0100 Subject: [PATCH] Actually return a response with timeout=0 --- syncapi/sync/requestpool.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 4908700dd..7b9526b53 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -381,11 +381,14 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi. // they weren't always doing, resulting in flakey tests. if !syncReq.Response.HasUpdates() { syncReq.Since = currentPos - syncReq.Timeout = syncReq.Timeout - time.Since(startTime) - if syncReq.Timeout < 0 { - syncReq.Timeout = 0 + // do not loop again if the ?timeout= is 0 as that means "return immediately" + if syncReq.Timeout > 0 { + syncReq.Timeout = syncReq.Timeout - time.Since(startTime) + if syncReq.Timeout < 0 { + syncReq.Timeout = 0 + } + continue } - continue } }