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

[tor-commits] [stem/master] Save value rather than invalidate getconf cache in CONF_CHANGED events



commit fa1614d20ab57c57e55fcbdb39bece229026bc2b
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date:   Mon May 14 19:04:32 2018 +0000

    Save value rather than invalidate getconf cache in CONF_CHANGED events
    
    This makes use of the new 'changed' and 'unset' attributes of the event.
    
    Partially fixes #25821
---
 stem/control.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/stem/control.py b/stem/control.py
index bd98f1bc..c67de63c 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1064,7 +1064,13 @@ class Controller(BaseController):
 
     def _confchanged_listener(event):
       if self.is_caching_enabled():
-        to_cache = dict((k.lower(), None) for k in event.config)
+        to_cache_changed = dict((k.lower(), v) for k, v in event.changed.items())
+        to_cache_unset = dict((k.lower(), []) for k in event.unset)  # [] represents None value in cache
+
+        to_cache = {}
+        to_cache.update(to_cache_changed)
+        to_cache.update(to_cache_unset)
+
         self._set_cache(to_cache, 'getconf')
 
         self._confchanged_cache_invalidation(to_cache)



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