[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r22585: {arm} fix: shouldn't cache undefined fingerprint (happens during s (arm/trunk/util)
Author: atagar
Date: 2010-07-04 02:47:56 +0000 (Sun, 04 Jul 2010)
New Revision: 22585
Modified:
arm/trunk/util/torTools.py
Log:
fix: shouldn't cache undefined fingerprint (happens during startup and no known event to clear cache on)
Modified: arm/trunk/util/torTools.py
===================================================================
--- arm/trunk/util/torTools.py 2010-07-04 02:45:02 UTC (rev 22584)
+++ arm/trunk/util/torTools.py 2010-07-04 02:47:56 UTC (rev 22585)
@@ -506,7 +506,7 @@
default - result if the query fails
"""
- return self._getRelayAttr("fingerprint", default)
+ return self._getRelayAttr("fingerprint", default, False)
def getMyFlags(self, default = None):
"""
@@ -768,14 +768,16 @@
self._cachedParam["descEntry"] = None
self._cachedParam["bwObserved"] = None
- def _getRelayAttr(self, key, default):
+ def _getRelayAttr(self, key, default, cacheUndefined = True):
"""
Provides information associated with this relay, using the cached value if
available and otherwise looking it up.
Arguments:
- key - parameter being queried (from CACHE_ARGS)
- default - value to be returned if undefined
+ key - parameter being queried (from CACHE_ARGS)
+ default - value to be returned if undefined
+ cacheUndefined - caches when values are undefined, avoiding further
+ lookups if true
"""
currentVal = self._cachedParam[key]
@@ -850,7 +852,7 @@
# cache value
if result: self._cachedParam[key] = result
- else: self._cachedParam[key] = UNKNOWN
+ elif cacheUndefined: self._cachedParam[key] = UNKNOWN
elif currentVal == UNKNOWN: result = currentVal
self.connLock.release()