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

[or-cvs] r18083: {torflow} Add FetchUselessDescriptors to metatroller and statssplitter (in torflow/trunk: . NetworkScanners)



Author: mikeperry
Date: 2009-01-11 18:13:38 -0500 (Sun, 11 Jan 2009)
New Revision: 18083

Modified:
   torflow/trunk/NetworkScanners/statsplitter.py
   torflow/trunk/metatroller.py
Log:

Add FetchUselessDescriptors to metatroller and statssplitter.



Modified: torflow/trunk/NetworkScanners/statsplitter.py
===================================================================
--- torflow/trunk/NetworkScanners/statsplitter.py	2009-01-11 23:12:57 UTC (rev 18082)
+++ torflow/trunk/NetworkScanners/statsplitter.py	2009-01-11 23:13:38 UTC (rev 18083)
@@ -9,14 +9,24 @@
 from TorCtl.TorUtil import control_port, control_host
 from TorCtl.TorUtil import *
 from TorCtl.PathSupport import *
+import atexit
 
 TorUtil.loglevel = "NOTICE"
 
+
+def cleanup(c, f):
+  print "Resetting FetchUselessDescriptors to "+f
+  c.set_option("FetchUselessDescriptors", f) 
+  
+
 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 s.connect((control_host,control_port))
 c = Connection(s)
 c.debug(file("control.log", "w"))
 c.authenticate()
+FUDValue = c.get_option("FetchUselessDescriptors")[0][1]
+c.set_option("FetchUselessDescriptors", "1") 
+atexit.register(cleanup, *(c, FUDValue))
 nslist = c.get_network_status()
 sorted_rlist = c.read_routers(c.get_network_status())
 

Modified: torflow/trunk/metatroller.py
===================================================================
--- torflow/trunk/metatroller.py	2009-01-11 23:12:57 UTC (rev 18082)
+++ torflow/trunk/metatroller.py	2009-01-11 23:13:38 UTC (rev 18083)
@@ -224,14 +224,16 @@
       s.write("500 "+buf+" is not a metatroller command\r\n")
   s.close()
 
-def cleanup(c, s):
+def cleanup(c, s, f):
+  plog("INFO", "Resetting __LeaveStreamsUnattached=0 and FetchUselessDescriptors="+f)
   c.set_option("__LeaveStreamsUnattached", "0")
+  c.set_option("FetchUselessDescriptors", f) 
   s.close()
 
-def listenloop(c, h):
+def listenloop(c, h, f):
   """Loop that handles metatroller commands"""
   srv = ListenSocket(meta_host, meta_port)
-  atexit.register(cleanup, *(c, srv))
+  atexit.register(cleanup, *(c, srv, f))
   while 1:
     client = srv.accept()
     if not client: break
@@ -255,11 +257,12 @@
           TorCtl.EVENT_TYPE.CIRC,
           TorCtl.EVENT_TYPE.STREAM_BW,
           TorCtl.EVENT_TYPE.NEWDESC], True)
-  c.set_option("__LeaveStreamsUnattached", "1")
+  c.set_option("__LeaveStreamsUnattached", "1") 
+  f = c.get_option("FetchUselessDescriptors")[0][1]
+  c.set_option("FetchUselessDescriptors", "1") 
 
+  return (c,h,f)
 
-  return (c,h)
-
 def main(argv):
   listenloop(*startup())