Commit ca81c6d3 authored by Julien Muchembled's avatar Julien Muchembled

registry: do not retry/wait forever if something goes wrong with babeld

babeld could be in bad state, or it could be incompatible (too old or too new).
parent 896bc9de
...@@ -175,7 +175,10 @@ SetCostMultiplier = Packet(2, ...@@ -175,7 +175,10 @@ SetCostMultiplier = Packet(2,
Struct("B", "set_cost_multiplier", "flags")) Struct("B", "set_cost_multiplier", "flags"))
class ConnectionClosed(Exception): class BabelException(Exception): pass
class ConnectionClosed(BabelException):
def __str__(self): def __str__(self):
return "connection to babeld closed (%s)" % self.args return "connection to babeld closed (%s)" % self.args
......
...@@ -102,16 +102,18 @@ class RegistryServer(object): ...@@ -102,16 +102,18 @@ class RegistryServer(object):
def request_dump(self): def request_dump(self):
assert self.peers_lock.locked() assert self.peers_lock.locked()
def abort():
raise ctl.BabelException
self._wait_dump = True self._wait_dump = True
while True: for _ in 0, 1:
self.ctl.request_dump() self.ctl.request_dump()
try: try:
while self._wait_dump: while self._wait_dump:
args = {}, {}, () args = {}, {}, ((time.time() + 5, abort),)
self.ctl.select(*args) self.ctl.select(*args)
utils.select(*args) utils.select(*args)
break break
except ctl.ConnectionClosed: except ctl.BabelException:
self.ctl.reset() self.ctl.reset()
def babel_dump(self): def babel_dump(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment