[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] fix: Store the error when there is not destination
commit e835710e4a59c7255211e5a67a4e2a3b5c831371
Author: juga0 <juga@xxxxxxxxxx>
Date: Fri Mar 22 16:15:56 2019 +0000
fix: Store the error when there is not destination
---
sbws/core/scanner.py | 27 ++++++++++++++++-----------
sbws/lib/resultdump.py | 9 +++++++++
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/sbws/core/scanner.py b/sbws/core/scanner.py
index d82aaca..5b28637 100644
--- a/sbws/core/scanner.py
+++ b/sbws/core/scanner.py
@@ -13,7 +13,7 @@ from ..lib.circuitbuilder import GapsCircuitBuilder as CB
from ..lib.resultdump import ResultDump
from ..lib.resultdump import (
ResultSuccess, ResultErrorCircuit, ResultErrorStream,
- ResultErrorSecondRelay, ResultError, # ResultErrorDestination
+ ResultErrorSecondRelay, ResultError, ResultErrorDestination
)
from ..lib.relaylist import RelayList
from ..lib.relayprioritizer import RelayPrioritizer
@@ -261,20 +261,25 @@ def measure_relay(args, conf, destinations, cb, rl, relay):
]
# Pick a destionation
dest = destinations.next()
- # If there is no any destination at this point, it can not continue.
+ # When there're no any functional destinations.
if not dest:
- # XXX: this should return a ResultError
- # instead of stopping the scanner once a destination can be recovered.
+ # NOTE: When there're still functional destinations but only one of
+ # them fail, the error will be included in `ResultErrorStream`.
+ # Since this is being executed in a thread, the scanner can not
+ # be stop here, but the `end_event` signal can be set so that the
+ # main thread stop the scanner.
+ # It might be useful to store the fact that the destinations fail,
+ # so store here the error, and set the signal once the error is stored
+ # (in `resultump`).
log.critical("There are not any functional destinations.\n"
"It is recommended to set several destinations so that "
"the scanner can continue if one fails.")
- # NOTE: Because this is executed in a thread, stop_threads can not
- # be call from here, it has to be call from the main thread.
- # Instead set the singleton end event, that will call stop_threads
- # from the main process.
- # Errors with only one destination are set in ResultErrorStream.
- settings.end_event.set()
- return None
+ reason = "No functional destinations"
+ # Resultdump will set end_event after storing the error
+ return [
+ ResultErrorDestination(relay, [], '', our_nick, msg=reason),
+ ]
+
# Pick a relay to help us measure the given relay. If the given relay is an
# exit, then pick a non-exit. Otherwise pick an exit.
helper = None
diff --git a/sbws/lib/resultdump.py b/sbws/lib/resultdump.py
index 2ebfa20..f7ec55b 100644
--- a/sbws/lib/resultdump.py
+++ b/sbws/lib/resultdump.py
@@ -776,6 +776,15 @@ class ResultDump:
"destination {}: {}".format(
result.fingerprint, result.nickname, result.circ,
result.dest_url, result.msg)
+ # When the error is that there are not more functional destinations.
+ if result.type == "error-destination":
+ log.info("Shutting down because there are not functional "
+ "destinations.")
+ # NOTE: Because this is executed in a thread, stop_threads can not
+ # be call from here, it has to be call from the main thread.
+ # Instead set the singleton end event, that will call stop_threads
+ # from the main process.
+ settings.end_event.set()
log.info(msg)
def enter(self):
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits