Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Notary server: make requests to origins in parallel
Browse files Browse the repository at this point in the history
... else we're guaranteed to time out.
  • Loading branch information
richvdh committed Jun 3, 2019
1 parent def5ea4 commit c5d60ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 9 additions & 1 deletion synapse/crypto/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,15 @@ def __init__(self, hs):
self.client = hs.get_http_client()

def get_keys(self, keys_to_fetch):
"""see KeyFetcher.get_keys"""
"""
Args:
keys_to_fetch (dict[str, iterable[str]]):
the keys to be fetched. server_name -> key_ids
Returns:
Deferred[dict[str, dict[str, synapse.storage.keys.FetchKeyResult|None]]]:
map from server_name -> key_id -> FetchKeyResult
"""

results = {}

Expand Down
12 changes: 2 additions & 10 deletions synapse/rest/key/v2/remote_key_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from twisted.web.server import NOT_DONE_YET

from synapse.api.errors import Codes, SynapseError
from synapse.crypto.keyring import KeyLookupError, ServerKeyFetcher
from synapse.crypto.keyring import ServerKeyFetcher
from synapse.http.server import respond_with_json_bytes, wrap_json_request_handler
from synapse.http.servlet import parse_integer, parse_json_object_from_request

Expand Down Expand Up @@ -215,15 +215,7 @@ def query_keys(self, request, query, query_remote_on_cache_miss=False):
json_results.add(bytes(result["key_json"]))

if cache_misses and query_remote_on_cache_miss:
for server_name, key_ids in cache_misses.items():
try:
yield self.fetcher.get_server_verify_key_v2_direct(
server_name, key_ids
)
except KeyLookupError as e:
logger.info("Failed to fetch key: %s", e)
except Exception:
logger.exception("Failed to get key for %r", server_name)
yield self.fetcher.get_keys(cache_misses)
yield self.query_keys(
request, query, query_remote_on_cache_miss=False
)
Expand Down

0 comments on commit c5d60ea

Please sign in to comment.