chiark / gitweb /
peerdb/tripe-newpeers.in: Don't start duplicate resolver queries.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 19 Jul 2014 16:22:37 +0000 (17:22 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 19 Jul 2014 16:22:37 +0000 (17:22 +0100)
Resolver queries are indexed by query domain name.  Previously, if we
find another place which wants the same name resolved, we'd overwrite
the existing query with the new one, which causes the old one to be
cancelled (despite it possibly having made progress).

(This also avoids tickling a bug in mLib's handling of aborted queries,
fixed separately.)

peerdb/tripe-newpeers.in

index d720584..aa9ccfc 100644 (file)
@@ -75,11 +75,12 @@ class BulkResolver (object):
 
   def prepare(me, host):
     """Prime the resolver to resolve the name HOST."""
-    me._resolvers[host] = M.SelResolveByName \
-                          (host,
-                           lambda name, alias, addr:
-                             me._resolved(host, addr[0]),
-                           lambda: me._resolved(host, None))
+    if host not in me._resolvers:
+      me._resolvers[host] = M.SelResolveByName \
+                            (host,
+                             lambda name, alias, addr:
+                               me._resolved(host, addr[0]),
+                             lambda: me._resolved(host, None))
 
   def run(me):
     """Run the background DNS resolver until it's finished."""