commit 65e53b7563e4ade74ac8376726bfe07636059238 Author: Nick Mathewson nickm@torproject.org Date: Thu Mar 14 13:42:04 2019 -0400
wait_for_bootstrap: fix a race condition
Two problems here: - The node status that we report on failure was not the same as the most recent status that we checked. This meant that we could declare that we weren't bootstrapped, while declaring that every node was bootstrapped
- In addition to sleeping between the bootstrap checks, we also slept after our final bootstrap check. This would increase the likelihood of hitting the first bug above. --- lib/chutney/TorNet.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py index 4aec528..e48c1b7 100644 --- a/lib/chutney/TorNet.py +++ b/lib/chutney/TorNet.py @@ -1190,22 +1190,28 @@ class Network(object): delay = 0.5 controllers = [n.getController() for n in self._nodes] elapsed = 0.0 - while elapsed < limit: + most_recent_status = [ None ] * len(controllers) + while True: all_bootstrapped = True + most_recent_status = [ ] for c in controllers: - if not c.isBootstrapped(): + pct, kwd, msg = c.getLastBootstrapStatus() + most_recent_status.append((pct, kwd, msg)) + if pct != 100: all_bootstrapped = False - break + if all_bootstrapped: print("Everything bootstrapped after %s sec"%elapsed) return True + if elapsed >= limit: + break time.sleep(delay) elapsed += delay
print("Bootstrap failed. Node status:") - for c in controllers: + for c, status in zip(controllers,most_recent_status): c.check(listRunning=False, listNonRunning=True) - print("{}: {}".format(c.getNick(), c.getLastBootstrapStatus())) + print("{}: {}".format(c.getNick(), status))
return False
tor-commits@lists.torproject.org