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

[tor-commits] [arm/master] fix: pausing interface could cause crash



commit 86325e6d124f0b2e5a4826938f2f493495fed9b7
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Jul 28 11:25:07 2011 -0700

    fix: pausing interface could cause crash
    
    Creating the pause buffer for the bandwidth graph could trigger a panel redraw,
    which in turn attempted to use the uninitialized pause value.
---
 src/cli/graphing/bandwidthStats.py |   11 ++++++++---
 src/util/panel.py                  |    2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/cli/graphing/bandwidthStats.py b/src/cli/graphing/bandwidthStats.py
index f1891f9..654443c 100644
--- a/src/cli/graphing/bandwidthStats.py
+++ b/src/cli/graphing/bandwidthStats.py
@@ -35,7 +35,7 @@ class BandwidthStats(graphPanel.GraphStats):
   Uses tor BW events to generate bandwidth usage graph.
   """
   
-  def __init__(self, config=None):
+  def __init__(self, config=None, isPauseBuffer=False):
     graphPanel.GraphStats.__init__(self)
     
     self.inputConfig = config
@@ -56,7 +56,7 @@ class BandwidthStats(graphPanel.GraphStats):
     # rate/burst and if tor's using accounting
     conn = torTools.getConn()
     self._titleStats, self.isAccounting = [], False
-    self.resetListener(conn, torTools.State.INIT) # initializes values
+    if not isPauseBuffer: self.resetListener(conn, torTools.State.INIT) # initializes values
     conn.addStatusListener(self.resetListener)
     
     # Initialized the bandwidth totals to the values reported by Tor. This
@@ -78,9 +78,14 @@ class BandwidthStats(graphPanel.GraphStats):
       self.initialSecondaryTotal = int(writeTotal) / 1024 # Bytes -> KB
   
   def clone(self, newCopy=None):
-    if not newCopy: newCopy = BandwidthStats(self.inputConfig)
+    if not newCopy: newCopy = BandwidthStats(self.inputConfig, True)
     newCopy.accountingLastUpdated = self.accountingLastUpdated
     newCopy.accountingInfo = self.accountingInfo
+    
+    # attributes that would have been initialized from calling the resetListener
+    newCopy.isAccounting = self.isAccounting
+    newCopy._titleStats = self._titleStats
+    
     return graphPanel.GraphStats.clone(self, newCopy)
   
   def resetListener(self, conn, eventType):
diff --git a/src/util/panel.py b/src/util/panel.py
index bb47726..732610c 100644
--- a/src/util/panel.py
+++ b/src/util/panel.py
@@ -186,7 +186,7 @@ class Panel():
     """
     
     if not attr in self.pauseAttr: return None
-    elif self.isPaused(): return self.pauseBuffer[attr]
+    elif self.paused: return self.pauseBuffer[attr]
     else: return self.__dict__.get(attr)
   
   def copyAttr(self, attr):



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