Fixed timeout variable scope issues

Partially-Fixes: #1473210
Change-Id: I5f6555fd6a00f2dc16ea120b598b21d08ef6b52a
This commit is contained in:
Graham Hayes 2015-07-16 14:53:12 +01:00
parent 16c84d40d7
commit 92d54232f9

View File

@ -311,20 +311,22 @@ def do_axfr(zone_name, servers, timeout=None, source=None):
Performs an AXFR for a given zone name
"""
random.shuffle(servers)
timeout = timeout or 10
timeout = timeout or cfg.CONF["service:mdns"].xfr_timeout
xfr = None
for srv in servers:
timeout = eventlet.Timeout(timeout)
to = eventlet.Timeout(timeout)
log_info = {'name': zone_name, 'host': srv}
try:
LOG.info(_LI("Doing AXFR for %(name)s from %(host)s") % log_info)
xfr = dns.query.xfr(srv['ip'], zone_name, relativize=False,
timeout=1, port=srv['port'], source=source)
raw_zone = dns.zone.from_xfr(xfr, relativize=False)
break
except eventlet.Timeout as t:
if t == timeout:
if t == to:
msg = _LE("AXFR timed out for %(name)s from %(host)s")
LOG.error(msg % log_info)
continue
@ -341,7 +343,7 @@ def do_axfr(zone_name, servers, timeout=None, source=None):
"Trying next server.")
LOG.exception(msg % log_info)
finally:
timeout.cancel()
to.cancel()
continue
else:
msg = _LE("XFR failed for %(name)s. No servers in %(servers)s was "