aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Faelligen <tfaelligen@gmail.com>2022-05-13 10:24:26 +0200
committerTill Faelligen <tfaelligen@gmail.com>2022-05-13 10:28:00 +0200
commitb57fdcc82d0c57ae3eed401e7b9891cc9b53a8d3 (patch)
treec8c6da1bdb726c5acedd31dd9e7f2e702176fa87
parent870f9b0c3f288950ab843b048485a0767e177bd1 (diff)
Only try to get OTKs if the context isn't done yet
-rw-r--r--syncapi/sync/requestpool.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go
index 30c490df..fdf46cdd 100644
--- a/syncapi/sync/requestpool.go
+++ b/syncapi/sync/requestpool.go
@@ -253,9 +253,12 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi.
// We should always try to include OTKs in sync responses, otherwise clients might upload keys
// even if that's not required. See also:
// https://github.com/matrix-org/synapse/blob/29f06704b8871a44926f7c99e73cf4a978fb8e81/synapse/rest/client/sync.py#L276-L281
- err = internal.DeviceOTKCounts(syncReq.Context, rp.keyAPI, syncReq.Device.UserID, syncReq.Device.ID, syncReq.Response)
- if err != nil {
- syncReq.Log.WithError(err).Error("failed to get OTK counts")
+ // Only try to get OTKs if the context isn't already done.
+ if syncReq.Context.Err() == nil {
+ err = internal.DeviceOTKCounts(syncReq.Context, rp.keyAPI, syncReq.Device.UserID, syncReq.Device.ID, syncReq.Response)
+ if err != nil && err != context.Canceled {
+ syncReq.Log.WithError(err).Warn("failed to get OTK counts")
+ }
}
return util.JSONResponse{
Code: http.StatusOK,