mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-16 11:23:11 -06:00
Fix the sync api returning an empty sync response when reaching timeout, regardless of the since token
This commit is contained in:
parent
2133e6bf59
commit
176f088215
|
|
@ -84,17 +84,15 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
||||||
userStreamListener := rp.notifier.GetListener(*syncReq)
|
userStreamListener := rp.notifier.GetListener(*syncReq)
|
||||||
defer userStreamListener.Close()
|
defer userStreamListener.Close()
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
select {
|
||||||
// Wait for notifier to wake us up
|
// Wait for notifier to wake us up
|
||||||
case <-userStreamListener.GetNotifyChannel(currPos):
|
case <-userStreamListener.GetNotifyChannel(currPos):
|
||||||
currPos = userStreamListener.GetStreamPosition()
|
currPos = userStreamListener.GetStreamPosition()
|
||||||
// Or for timeout to expire
|
// Or for timeout to expire
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
return util.JSONResponse{
|
// We just need to ensure we get out of the select after reaching the
|
||||||
Code: http.StatusOK,
|
// timeout, but there's nothing specific we want to do in this case
|
||||||
JSON: types.NewResponse(currPos),
|
// apart from that, so we do nothing.
|
||||||
}
|
|
||||||
// Or for the request to be cancelled
|
// Or for the request to be cancelled
|
||||||
case <-req.Context().Done():
|
case <-req.Context().Done():
|
||||||
return httputil.LogThenError(req, req.Context().Err())
|
return httputil.LogThenError(req, req.Context().Err())
|
||||||
|
|
@ -109,14 +107,11 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return httputil.LogThenError(req, err)
|
return httputil.LogThenError(req, err)
|
||||||
}
|
}
|
||||||
if !syncData.IsEmpty() {
|
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
JSON: syncData,
|
JSON: syncData,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rp *RequestPool) currentSyncForUser(req syncRequest, currentPos types.StreamPosition) (res *types.Response, err error) {
|
func (rp *RequestPool) currentSyncForUser(req syncRequest, currentPos types.StreamPosition) (res *types.Response, err error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue