diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2020-07-22 13:44:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-22 13:44:16 +0100 |
commit | 923c995023b1113f7b859f5b961a2d84666c1761 (patch) | |
tree | bdcab89d519e751fc7a7c34ce6761e19949793c9 /synapse/rest | |
parent | Add debugging to sync response generation (#7929) (diff) | |
download | synapse-923c995023b1113f7b859f5b961a2d84666c1761.tar.xz |
Skip serializing /sync response if client has disconnected (#7927)
... it's a load of work which may be entirely redundant.
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/client/v2_alpha/sync.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/synapse/rest/client/v2_alpha/sync.py b/synapse/rest/client/v2_alpha/sync.py index 9d81150729..a5c24fbd63 100644 --- a/synapse/rest/client/v2_alpha/sync.py +++ b/synapse/rest/client/v2_alpha/sync.py @@ -178,6 +178,12 @@ class SyncRestServlet(RestServlet): full_state=full_state, ) + # the client may have disconnected by now; don't bother to serialize the + # response if so. + if request._disconnected: + logger.info("Client has disconnected; not serializing response.") + return 200, {} + time_now = self.clock.time_msec() response_content = await self.encode_response( time_now, sync_result, requester.access_token_id, filter_collection |