[tor-commits] [nyx/master] Halting trackers when tor disconnects
atagar at torproject.org
atagar at torproject.org
Mon Feb 15 14:45:09 UTC 2016
commit ea4d683b1c46da42b50251c0dcb57f860f4d8609
Author: Damian Johnson <atagar at torproject.org>
Date: Wed Feb 10 12:17:57 2016 -0800
Halting trackers when tor disconnects
The connection tracker did this, but applying it to all trackers.
---
nyx/controller.py | 19 +++----------------
nyx/log_panel.py | 8 +++++---
nyx/util/tracker.py | 3 +++
3 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/nyx/controller.py b/nyx/controller.py
index dc9f53b..fcc6239 100644
--- a/nyx/controller.py
+++ b/nyx/controller.py
@@ -8,7 +8,6 @@ import time
import curses
import threading
-import nyx.arguments
import nyx.menu.menu
import nyx.popups
import nyx.header_panel
@@ -38,7 +37,6 @@ def conf_handler(key, value):
CONFIG = conf.config_dict('nyx', {
- 'startup.events': 'N3',
'features.acsSupport': True,
'features.panels.show.graph': True,
'features.panels.show.log': True,
@@ -104,8 +102,7 @@ def init_controller(stdscr, start_time):
first_page_panels.append(nyx.graph_panel.GraphPanel(stdscr))
if CONFIG['features.panels.show.log']:
- expanded_events = nyx.arguments.expand_events(CONFIG['startup.events'])
- first_page_panels.append(nyx.log_panel.LogPanel(stdscr, expanded_events))
+ first_page_panels.append(nyx.log_panel.LogPanel(stdscr))
if first_page_panels:
page_panels.append(first_page_panels)
@@ -434,18 +431,8 @@ def heartbeat_check(is_unresponsive):
def conn_reset_listener(controller, event_type, _):
- """
- Pauses connection resolution when tor's shut down, and resumes with the new
- pid if started again.
- """
-
- resolver = nyx.util.tracker.get_connection_tracker()
-
- if resolver.is_alive():
- resolver.set_paused(event_type == State.CLOSED)
-
- if event_type == State.CLOSED:
- log.notice('Tor control port closed')
+ if event_type == State.CLOSED:
+ log.notice('Tor control port closed')
def start_nyx(stdscr):
diff --git a/nyx/log_panel.py b/nyx/log_panel.py
index 37e9e21..708a679 100644
--- a/nyx/log_panel.py
+++ b/nyx/log_panel.py
@@ -29,15 +29,16 @@ def conf_handler(key, value):
CONFIG = conf.config_dict('nyx', {
+ 'attr.log_color': {},
+ 'cache.log_panel.size': 1000,
'features.logFile': '',
'features.log.showDuplicateEntries': False,
'features.log.prepopulate': True,
'features.log.prepopulateReadLimit': 5000,
'features.log.maxRefreshRate': 300,
'features.log.regex': [],
- 'cache.log_panel.size': 1000,
'msg.misc.event_types': '',
- 'attr.log_color': {},
+ 'startup.events': 'N3',
}, conf_handler)
# The height of the drawn content is estimated based on the last time we redrew
@@ -61,11 +62,12 @@ class LogPanel(panel.Panel, threading.Thread):
from tor's log file if it exists.
"""
- def __init__(self, stdscr, logged_events):
+ def __init__(self, stdscr):
panel.Panel.__init__(self, stdscr, 'log', 0)
threading.Thread.__init__(self)
self.setDaemon(True)
+ logged_events = nyx.arguments.expand_events(CONFIG['startup.events'])
self._event_log = nyx.util.log.LogGroup(CONFIG['cache.log_panel.size'], group_by_day = True)
self._event_types = nyx.util.log.listen_for_events(self._register_tor_event, logged_events)
self._log_file = nyx.util.log.LogFileOutput(CONFIG['features.logFile'])
diff --git a/nyx/util/tracker.py b/nyx/util/tracker.py
index f218630..8aa1181 100644
--- a/nyx/util/tracker.py
+++ b/nyx/util/tracker.py
@@ -460,6 +460,9 @@ class Daemon(threading.Thread):
self._process_pid = tor_pid
self._process_name = tor_cmd if tor_cmd else 'tor'
+ elif event_type == stem.contorl.State.CLOSED:
+ self._process_pid = None
+ self._process_name = None
def __enter__(self):
self.start()
More information about the tor-commits
mailing list