mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Fix timed out syncs
This commit is contained in:
parent
a588f9061b
commit
722510ac9f
|
|
@ -144,8 +144,6 @@ var waitingSyncRequests = prometheus.NewGauge(
|
||||||
// called in a dedicated goroutine for this request. This function will block the goroutine
|
// called in a dedicated goroutine for this request. This function will block the goroutine
|
||||||
// until a response is ready, or it times out.
|
// until a response is ready, or it times out.
|
||||||
func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.Device) util.JSONResponse {
|
func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
var syncData *types.Response
|
|
||||||
|
|
||||||
// Extract values from request
|
// Extract values from request
|
||||||
syncReq, err := newSyncRequest(req, *device, rp.db)
|
syncReq, err := newSyncRequest(req, *device, rp.db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -174,11 +172,11 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
|
||||||
select {
|
select {
|
||||||
case <-waitctx.Done(): // Caller gave up
|
case <-waitctx.Done(): // Caller gave up
|
||||||
waitcancel()
|
waitcancel()
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: syncData}
|
return util.JSONResponse{Code: http.StatusOK, JSON: syncReq.Response}
|
||||||
|
|
||||||
case <-timer.C: // Timeout reached
|
case <-timer.C: // Timeout reached
|
||||||
waitcancel()
|
waitcancel()
|
||||||
return util.JSONResponse{Code: http.StatusOK, JSON: syncData}
|
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