[tor-commits] [stem/master] Updating GETCONF cache after CONF_CHANGED events

atagar at torproject.org atagar at torproject.org
Mon May 6 02:06:23 UTC 2013


commit de576cad4bbdd4901ee1857334a7420593ef2458
Author: Sreenatha Bhatlapenumarthi <sreenatha.dev at gmail.com>
Date:   Thu Apr 25 06:36:27 2013 +0530

    Updating GETCONF cache after CONF_CHANGED events
    
    https://trac.torproject.org/7713
---
 stem/control.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 2312712..2e83a64 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -675,6 +675,19 @@ class Controller(BaseController):
 
     self.add_event_listener(_sighup_listener, EventType.SIGNAL)
 
+    def _confchanged_listener(event):
+      if self.is_caching_enabled():
+        for param, value in event.config.items():
+          cache_key = "getconf.%s" % param.lower()
+
+          if cache_key in self._request_cache:
+            del self._request_cache[cache_key]
+
+          if param.lower() == "exitpolicy" and "exit_policy" in self._request_cache:
+            del self._request_cache["exit_policy"]
+
+    self.add_event_listener(_confchanged_listener, EventType.CONF_CHANGED)
+
   def connect(self):
     super(Controller, self).connect()
     self.clear_cache()



More information about the tor-commits mailing list