From 30fc50d0997f9ea7daf29d506faf3c5977f7d590 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 18 May 2022 18:49:20 +0100 Subject: [PATCH] Honour timeouts --- syncapi/sync/requestpool.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 77dd56311..4908700dd 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -253,6 +253,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi. // loop until we get some data for { + startTime := time.Now() currentPos := rp.Notifier.CurrentPosition() // if the since token matches the current positions, wait via the notifier @@ -380,6 +381,10 @@ 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 + } continue } }