summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-31 10:23:48 +0100
committerErik Johnston <erik@matrix.org>2016-03-31 10:23:48 +0100
commitf9d3665c8841335cd70325dd758b4193c462ca60 (patch)
tree453bb5226f19a2700253f27fa3c8a6f7d1e26c75
parentRead from DNS cache if within TTL (diff)
downloadsynapse-f9d3665c8841335cd70325dd758b4193c462ca60.tar.xz
Allow clock to be passed in to func
-rw-r--r--synapse/http/endpoint.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/synapse/http/endpoint.py b/synapse/http/endpoint.py
index e80d00e2af..bc28a2959a 100644
--- a/synapse/http/endpoint.py
+++ b/synapse/http/endpoint.py
@@ -155,10 +155,10 @@ class SRVClientEndpoint(object):
 
 
 @defer.inlineCallbacks
-def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE):
+def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE, clock=time):
     cache_entry = cache.get(service_name, None)
     if cache_entry:
-        if all(s.expires > int(time.time()) for s in cache_entry):
+        if all(s.expires > int(clock.time()) for s in cache_entry):
             servers = list(cache_entry)
             defer.returnValue(servers)
 
@@ -199,7 +199,7 @@ def resolve_service(service_name, dns_client=client, cache=SERVER_CACHE):
                         port=int(payload.port),
                         priority=int(payload.priority),
                         weight=int(payload.weight),
-                        expires=int(time.time()) + host_ttl,
+                        expires=int(clock.time()) + host_ttl,
                     ))
 
         servers.sort()