diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2017-09-25 09:51:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-25 09:51:39 +0100 |
commit | 79b3cf3e02a3816791a8a0674bbac261b46abea9 (patch) | |
tree | be743229ed07a4f40e12f694209f79202d5e6e18 /synapse | |
parent | Do an AAAA lookup on SRV record targets (#2462) (diff) | |
download | synapse-79b3cf3e02a3816791a8a0674bbac261b46abea9.tar.xz |
Fix logcontxt leak in keyclient (#2465)
preserve_context_over_function doesn't do what you want it to do.
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/crypto/keyclient.py | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/synapse/crypto/keyclient.py b/synapse/crypto/keyclient.py index c2bd64d6c2..f1fd488b90 100644 --- a/synapse/crypto/keyclient.py +++ b/synapse/crypto/keyclient.py @@ -13,14 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. - +from synapse.util import logcontext from twisted.web.http import HTTPClient from twisted.internet.protocol import Factory from twisted.internet import defer, reactor from synapse.http.endpoint import matrix_federation_endpoint -from synapse.util.logcontext import ( - preserve_context_over_fn, preserve_context_over_deferred -) import simplejson as json import logging @@ -43,14 +40,10 @@ def fetch_server_key(server_name, ssl_context_factory, path=KEY_API_V1): for i in range(5): try: - protocol = yield preserve_context_over_fn( - endpoint.connect, factory - ) - server_response, server_certificate = yield preserve_context_over_deferred( - protocol.remote_key - ) - defer.returnValue((server_response, server_certificate)) - return + with logcontext.PreserveLoggingContext(): + protocol = yield endpoint.connect(factory) + server_response, server_certificate = yield protocol.remote_key + defer.returnValue((server_response, server_certificate)) except SynapseKeyClientError as e: logger.exception("Error getting key for %r" % (server_name,)) if e.status.startswith("4"): |