diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-05-12 16:37:50 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-05-12 16:37:50 +0100 |
commit | cffe6057fb59a4db622132a84b5ef88cf81f6bfd (patch) | |
tree | 173ebcd9a8c7c04ee3a4f733995a47c515e9c81a /synapse/crypto | |
parent | Merge branch 'notifier_unify' into notifier_performance (diff) | |
parent | Merge branch 'develop' into notifier_unify (diff) | |
download | synapse-cffe6057fb59a4db622132a84b5ef88cf81f6bfd.tar.xz |
Merge branch 'notifier_unify' into notifier_performance
Conflicts: synapse/notifier.py
Diffstat (limited to 'synapse/crypto')
-rw-r--r-- | synapse/crypto/keyclient.py | 17 | ||||
-rw-r--r-- | synapse/crypto/keyring.py | 8 |
2 files changed, 17 insertions, 8 deletions
diff --git a/synapse/crypto/keyclient.py b/synapse/crypto/keyclient.py index 4911f0896b..24f15f3154 100644 --- a/synapse/crypto/keyclient.py +++ b/synapse/crypto/keyclient.py @@ -18,7 +18,9 @@ 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 PreserveLoggingContext +from synapse.util.logcontext import ( + preserve_context_over_fn, preserve_context_over_deferred +) import simplejson as json import logging @@ -40,11 +42,14 @@ def fetch_server_key(server_name, ssl_context_factory, path=KEY_API_V1): for i in range(5): try: - with PreserveLoggingContext(): - protocol = yield endpoint.connect(factory) - server_response, server_certificate = yield protocol.remote_key - defer.returnValue((server_response, server_certificate)) - return + 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 except SynapseKeyClientError as e: logger.exception("Error getting key for %r" % (server_name,)) if e.status.startswith("4"): diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index 8709394b97..a859872ce2 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -26,7 +26,7 @@ from synapse.api.errors import SynapseError, Codes from synapse.util.retryutils import get_retry_limiter -from synapse.util.async import create_observer +from synapse.util.async import ObservableDeferred from OpenSSL import crypto @@ -111,6 +111,10 @@ class Keyring(object): if download is None: download = self._get_server_verify_key_impl(server_name, key_ids) + download = ObservableDeferred( + download, + consumeErrors=True + ) self.key_downloads[server_name] = download @download.addBoth @@ -118,7 +122,7 @@ class Keyring(object): del self.key_downloads[server_name] return ret - r = yield create_observer(download) + r = yield download.observe() defer.returnValue(r) @defer.inlineCallbacks |