Commit a06038c6 authored by Mike Perry's avatar Mike Perry
Browse files

Workaround strange issue with unmeasured flag parsing.

It seems like consensus/newdesc events are causing TorCtl to reset the
unmeasured flag when we shouldn't be. That is a TorCtl bug, but since there
may also be memory bloat issues with leaving the bwauthority_child processes
around anyway, just exit and let the parent restart the slice with a clean
consensus.
parent af5fa45c
......@@ -12,11 +12,14 @@ from signal import signal, SIGTERM, SIGKILL
# exit code to indicate scan completion
# make sure to update this in bwauthority_child.py as well
STOP_PCT_REACHED = 9
RESTART_SLICE = 1
# path to git repos (.git)
PATH_TO_TORFLOW_REPO = '../../.git/'
PATH_TO_TORCTL_REPO = '../../.git/modules/TorCtl/'
p = None
def main(argv):
(branch, head) = get_git_version(PATH_TO_TORFLOW_REPO)
plog('INFO', 'TorFlow Version: %s' % branch+' '+head)
......@@ -30,6 +33,8 @@ def main(argv):
p.wait()
if (p.returncode == 0):
slice_num += 1
elif (p.returncode == RESTART_SLICE):
plog('INFO', 'restarting slice_num '+str(slice_num))
elif (p.returncode == STOP_PCT_REACHED):
plog('INFO', 'restarting from slice 0')
slice_num = 0
......@@ -60,6 +65,7 @@ if __name__ == '__main__':
try:
main(s_argv)
except KeyboardInterrupt:
global p
p.kill()
plog('INFO', "Ctrl + C was pressed. Exiting ... ")
except Exception, e:
......
......@@ -72,6 +72,7 @@ __selmgr = PathSupport.SelectionManager(
# exit code to indicate scan completion
# make sure to update this in bwauthority.py as well
STOP_PCT_REACHED = 9
RESTART_SLICE = 1
def read_config(filename):
config = ConfigParser.SafeConfigParser()
......@@ -343,14 +344,6 @@ def main(argv):
hdlr.wait_for_consensus()
# We should go to sleep if there are less than 5 unmeasured nodes after
# consensus update
while min_unmeasured and hdlr.get_unmeasured() < min_unmeasured:
plog("NOTICE", "Less than "+str(min_unmeasured)+" unmeasured nodes ("+str(hdlr.get_unmeasured())+"). Sleeping for a bit")
time.sleep(3600) # Until next consensus arrives
plog("NOTICE", "Woke up from waiting for more unmeasured nodes. Getting consensus and checking again")
hdlr.wait_for_consensus()
# Now that we have the consensus, we shouldn't need to listen
# for new consensus events.
c.set_events([TorCtl.EVENT_TYPE.STREAM,
......@@ -358,6 +351,14 @@ def main(argv):
TorCtl.EVENT_TYPE.CIRC,
TorCtl.EVENT_TYPE.STREAM_BW], True)
# We should go to sleep if there are less than 5 unmeasured nodes after
# consensus update
if min_unmeasured and hdlr.get_unmeasured() < min_unmeasured:
plog("NOTICE", "Less than "+str(min_unmeasured)+" unmeasured nodes ("+str(hdlr.get_unmeasured())+"). Sleeping for a bit")
time.sleep(3600) # Until next consensus arrives
plog("NOTICE", "Woke up from waiting for more unmeasured nodes. Requesting slice restart.")
sys.exit(RESTART_SLICE)
pct_step = hdlr.rank_to_percent(nodes_per_slice)
plog("INFO", "Percent per slice is: "+str(pct_step))
if pct_step > 100: pct_step = 100
......
Supports Markdown
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