mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 09:53:10 -06:00
Fix initial / fullSync request
the initial/fullSync request sometimes crashed as the timout triggered before it finished.
Compare Synpase which got the same if: b23cb8fba8/synapse/handlers/sync.py (L192)
This commit is contained in:
parent
619fec6113
commit
653e7dc21f
|
|
@ -66,7 +66,9 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
||||||
// Whichever returns first is the one we will serve back to the client.
|
// Whichever returns first is the one we will serve back to the client.
|
||||||
timeoutChan := make(chan struct{})
|
timeoutChan := make(chan struct{})
|
||||||
timer := time.AfterFunc(syncReq.timeout, func() {
|
timer := time.AfterFunc(syncReq.timeout, func() {
|
||||||
|
if syncReq.timeout != 0 && syncReq.since != types.StreamPosition(0) && !syncReq.wantFullState {
|
||||||
close(timeoutChan) // signal that the timeout has expired
|
close(timeoutChan) // signal that the timeout has expired
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
done := make(chan util.JSONResponse)
|
done := make(chan util.JSONResponse)
|
||||||
|
|
@ -75,7 +77,9 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
||||||
// We stop the timer BEFORE calculating the response so the cpu work
|
// We stop the timer BEFORE calculating the response so the cpu work
|
||||||
// done to calculate the response is not timed. This stops us from
|
// done to calculate the response is not timed. This stops us from
|
||||||
// doing lots of work then timing out and sending back an empty response.
|
// doing lots of work then timing out and sending back an empty response.
|
||||||
|
if syncReq.timeout != 0 && syncReq.since != types.StreamPosition(0) && !syncReq.wantFullState {
|
||||||
timer.Stop()
|
timer.Stop()
|
||||||
|
}
|
||||||
syncData, err := rp.currentSyncForUser(*syncReq, currentPos)
|
syncData, err := rp.currentSyncForUser(*syncReq, currentPos)
|
||||||
var res util.JSONResponse
|
var res util.JSONResponse
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue