[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [arm/release] fix: skipping init actions that will fail
commit 388abe5d8b31b9c735569dbe0728b54e6111ee30
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Jun 19 15:11:54 2011 -0700
fix: skipping init actions that will fail
When we start and are detached from tor many actions (bandwidth prepopulation
and loading the torrc, for instance) will always fail. Skipping these actions
if there's no tor instance to avoid pointless work and log messages.
---
src/cli/configPanel.py | 4 +---
src/cli/controller.py | 11 ++---------
src/cli/torrcPanel.py | 14 ++++++++++++--
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/cli/configPanel.py b/src/cli/configPanel.py
index 33cec34..d76a528 100644
--- a/src/cli/configPanel.py
+++ b/src/cli/configPanel.py
@@ -201,9 +201,7 @@ class ConfigPanel(panel.Panel):
# initializes config contents if we're connected
conn = torTools.getConn()
conn.addStatusListener(self.resetListener)
-
- if conn.isAlive():
- self.resetListener(conn, torTools.State.INIT)
+ if conn.isAlive(): self.resetListener(conn, torTools.State.INIT)
def resetListener(self, conn, eventType):
# fetches configuration options if a new instance, otherewise keeps our
diff --git a/src/cli/controller.py b/src/cli/controller.py
index 51fbe2b..e20e023 100644
--- a/src/cli/controller.py
+++ b/src/cli/controller.py
@@ -110,7 +110,7 @@ def initController(stdscr, startTime):
except ValueError: pass # invalid stats, maybe connections when in blind mode
# prepopulates bandwidth values from state file
- if CONFIG["features.graph.bw.prepopulate"]:
+ if CONFIG["features.graph.bw.prepopulate"] and torTools.getConn().isAlive():
isSuccessful = bwStats.prepopulateFromState()
if isSuccessful: graphPanel.updateInterval = 4
@@ -461,7 +461,7 @@ def startTorMonitor(startTime):
conn = torTools.getConn()
torPid = conn.getMyPid()
- if not torPid:
+ if not torPid and conn.isAlive():
msg = "Unable to determine Tor's pid. Some information, like its resource usage will be unavailable."
log.log(CONFIG["log.unknownTorPid"], msg)
@@ -490,13 +490,6 @@ def startTorMonitor(startTime):
# hack to display a better (arm specific) notice if all resolvers fail
connections.RESOLVER_FINAL_FAILURE_MSG += " (connection related portions of the monitor won't function)"
- # loads the torrc and provides warnings in case of validation errors
- try:
- loadedTorrc = torConfig.getTorrc()
- loadedTorrc.load(True)
- loadedTorrc.logValidationIssues()
- except IOError: pass
-
# provides a notice about any event types tor supports but arm doesn't
missingEventTypes = cli.logPanel.getMissingEventTypes()
diff --git a/src/cli/torrcPanel.py b/src/cli/torrcPanel.py
index 2dc244f..c1bb3f9 100644
--- a/src/cli/torrcPanel.py
+++ b/src/cli/torrcPanel.py
@@ -42,7 +42,9 @@ class TorrcPanel(panel.Panel):
self._lastContentHeightArgs = None
# listens for tor reload (sighup) events
- torTools.getConn().addStatusListener(self.resetListener)
+ conn = torTools.getConn()
+ conn.addStatusListener(self.resetListener)
+ if conn.isAlive(): self.resetListener(conn, torTools.State.INIT)
def resetListener(self, conn, eventType):
"""
@@ -53,7 +55,15 @@ class TorrcPanel(panel.Panel):
eventType - type of event detected
"""
- if eventType in (torTools.State.INIT, torTools.State.RESET):
+ if eventType == torTools.State.INIT:
+ # loads the torrc and provides warnings in case of validation errors
+ try:
+ loadedTorrc = torConfig.getTorrc()
+ loadedTorrc.load(True)
+ loadedTorrc.logValidationIssues()
+ self.redraw(True)
+ except: pass
+ elif eventType == torTools.State.RESET:
try:
torConfig.getTorrc().load(True)
self.redraw(True)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits