From 253f76a0a544982cee2e908bf73ad450c7321fcb Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 May 2015 13:43:34 +0100 Subject: [PATCH 1/2] Don't always hit get_server_verify_key_v1_direct --- synapse/crypto/keyring.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index 2a5a8914c..35f9ac351 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -164,12 +164,17 @@ class Keyring(object): keys = yield self.get_server_verify_key_v2_direct( server_name, key_ids ) - except: - pass + except Exception as e: + logging.info( + "Unable to getting key %r for %r directly: %s %s", + key_ids, server_name, + type(e).__name__, str(e.message), + ) - keys = yield self.get_server_verify_key_v1_direct( - server_name, key_ids - ) + if keys is None: + keys = yield self.get_server_verify_key_v1_direct( + server_name, key_ids + ) for key_id in key_ids: if key_id in keys: From 291cba284bc79c68caa73c09a382e5bea38375d3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 19 May 2015 14:27:11 +0100 Subject: [PATCH 2/2] Handle the case when things return empty but non none things --- synapse/crypto/keyring.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/crypto/keyring.py b/synapse/crypto/keyring.py index 35f9ac351..aff69c5f8 100644 --- a/synapse/crypto/keyring.py +++ b/synapse/crypto/keyring.py @@ -159,7 +159,7 @@ class Keyring(object): ) with limiter: - if keys is None: + if not keys: try: keys = yield self.get_server_verify_key_v2_direct( server_name, key_ids @@ -171,7 +171,7 @@ class Keyring(object): type(e).__name__, str(e.message), ) - if keys is None: + if not keys: keys = yield self.get_server_verify_key_v1_direct( server_name, key_ids )