[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torflow/master] Workaround strange issue with unmeasured flag parsing.



commit a06038c682c9861c651bad798d27cb5096bf6db6
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
Date:   Sun May 31 19:17:52 2015 -0700

    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.
---
 NetworkScanners/BwAuthority/bwauthority.py       |    6 ++++++
 NetworkScanners/BwAuthority/bwauthority_child.py |   17 +++++++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/NetworkScanners/BwAuthority/bwauthority.py b/NetworkScanners/BwAuthority/bwauthority.py
index e190e7d..6a04542 100755
--- a/NetworkScanners/BwAuthority/bwauthority.py
+++ b/NetworkScanners/BwAuthority/bwauthority.py
@@ -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:
diff --git a/NetworkScanners/BwAuthority/bwauthority_child.py b/NetworkScanners/BwAuthority/bwauthority_child.py
index 1c5a0c1..a42a9b5 100755
--- a/NetworkScanners/BwAuthority/bwauthority_child.py
+++ b/NetworkScanners/BwAuthority/bwauthority_child.py
@@ -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

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits