[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r19618: {torctl} Prevent _generated from getting overwritten on router update (torctl/trunk/python/TorCtl)
Author: mikeperry
Date: 2009-06-02 17:14:29 -0400 (Tue, 02 Jun 2009)
New Revision: 19618
Modified:
torctl/trunk/python/TorCtl/PathSupport.py
torctl/trunk/python/TorCtl/SQLSupport.py
torctl/trunk/python/TorCtl/TorCtl.py
Log:
Prevent _generated from getting overwritten on router update.
Add a log line to let us know when we reset the _generated
stats. Relocate a session.clear() to before we drop tables,
which is better practice.
Modified: torctl/trunk/python/TorCtl/PathSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/PathSupport.py 2009-06-02 21:10:58 UTC (rev 19617)
+++ torctl/trunk/python/TorCtl/PathSupport.py 2009-06-02 21:14:29 UTC (rev 19618)
@@ -1304,6 +1304,7 @@
Resets accumulated state. Currently only clears the
ExactUniformGenerator state.
"""
+ plog("DEBUG", "Resetting _generated values for ExactUniformGenerator")
for r in self.routers.itervalues():
for g in xrange(0, len(r._generated)):
r._generated[g] = 0
Modified: torctl/trunk/python/TorCtl/SQLSupport.py
===================================================================
--- torctl/trunk/python/TorCtl/SQLSupport.py 2009-06-02 21:10:58 UTC (rev 19617)
+++ torctl/trunk/python/TorCtl/SQLSupport.py 2009-06-02 21:14:29 UTC (rev 19618)
@@ -460,6 +460,7 @@
_compute_filtered_ratios = Callable(_compute_filtered_ratios)
def reset():
+ tc_session.clear()
RouterStats.table.drop()
RouterStats.table.create()
for r in Router.query.all():
@@ -467,7 +468,6 @@
rs.router = r
r.stats = rs
tc_session.add(r)
- tc_session.clear()
tc_session.commit()
reset = Callable(reset)
Modified: torctl/trunk/python/TorCtl/TorCtl.py
===================================================================
--- torctl/trunk/python/TorCtl/TorCtl.py 2009-06-02 21:10:58 UTC (rev 19617)
+++ torctl/trunk/python/TorCtl/TorCtl.py 2009-06-02 21:14:29 UTC (rev 19618)
@@ -385,7 +385,7 @@
plog("ERROR", "Update of router "+self.nickname+"changes idhex!")
plog("DEBUG", "Updating refcount "+str(self.refcount)+" for "+self.idhex)
for i in new.__dict__.iterkeys():
- if i == "refcount": continue
+ if i == "refcount" or i == "_generated": continue
self.__dict__[i] = new.__dict__[i]
plog("DEBUG", "Updated refcount "+str(self.refcount)+" for "+self.idhex)