[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Cache get_hidden_service_conf() responses
commit 8e2ca2b42ccf4ac3e9db805926e7d259b6eaf9a5
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Jan 31 12:06:09 2016 -0800
Cache get_hidden_service_conf() responses
Nyx calls this quite a bit which is fine, but it bypasses our GETCONF cache.
Adding a cache for this similar to our exit policy cache. Even after just a few
seconds this caused thousands of calls so pretty important to nyx...
% grep 'GETCONF HiddenServiceOptions (runtime' /tmp/dump | wc -l
6943
---
stem/control.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/stem/control.py b/stem/control.py
index 8c30b28..cecc48b 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -2339,6 +2339,8 @@ class Controller(BaseController):
if param == 'exitpolicy':
self._set_cache({'exitpolicy': None})
+ elif 'hidden' in param:
+ self._set_cache({'hidden_service_conf': None})
# reset any getinfo parameters that can be changed by a SETCONF
@@ -2395,6 +2397,12 @@ class Controller(BaseController):
provided a default response
"""
+ service_dir_map = self._get_cache('hidden_service_conf')
+
+ if service_dir_map is not None:
+ log.trace('GETCONF HiddenServiceOptions (cache fetch)')
+ return service_dir_map
+
start_time = time.time()
try:
@@ -2444,6 +2452,7 @@ class Controller(BaseController):
else:
service_dir_map[directory][k] = v
+ self._set_cache({'hidden_service_conf': service_dir_map})
return service_dir_map
def set_hidden_service_conf(self, conf):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits