Honour timeouts

This commit is contained in:
Kegan Dougal 2022-05-18 18:49:20 +01:00
parent 07cb8b452a
commit 30fc50d099

View file

@ -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
}
}