mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-28 09:13:09 -06:00
Don't reset next batch position on timeout
This commit is contained in:
parent
722510ac9f
commit
c31a1767f7
|
|
@ -168,15 +168,21 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
|
||||||
// Use a subcontext so that we don't keep the StreamNotifyAfter
|
// Use a subcontext so that we don't keep the StreamNotifyAfter
|
||||||
// goroutines alive any longer than they really need to be.
|
// goroutines alive any longer than they really need to be.
|
||||||
waitctx, waitcancel := context.WithCancel(syncReq.Context)
|
waitctx, waitcancel := context.WithCancel(syncReq.Context)
|
||||||
|
giveup := func() util.JSONResponse {
|
||||||
|
waitcancel()
|
||||||
|
syncReq.Response.NextBatch = syncReq.Since
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusOK,
|
||||||
|
JSON: syncReq.Response,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-waitctx.Done(): // Caller gave up
|
case <-waitctx.Done(): // Caller gave up
|
||||||
waitcancel()
|
return giveup()
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: syncReq.Response}
|
|
||||||
|
|
||||||
case <-timer.C: // Timeout reached
|
case <-timer.C: // Timeout reached
|
||||||
waitcancel()
|
return giveup()
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: syncReq.Response}
|
|
||||||
|
|
||||||
case <-rp.pduStream.NotifyAfter(waitctx, syncReq.Since.PDUPosition):
|
case <-rp.pduStream.NotifyAfter(waitctx, syncReq.Since.PDUPosition):
|
||||||
case <-rp.typingStream.NotifyAfter(waitctx, syncReq.Since.TypingPosition):
|
case <-rp.typingStream.NotifyAfter(waitctx, syncReq.Since.TypingPosition):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue