Slightly improve the documentation of src/or/transports.c

Make it clear that a SIGHUP is not the only action that can cause a
config re-read.
This commit is contained in:
George Kadianakis 2014-04-08 17:19:51 +01:00 committed by Nick Mathewson
parent fa0c5da68b
commit 29c28d312c

View File

@ -51,35 +51,37 @@
* logic, because of race conditions that can cause dangling * logic, because of race conditions that can cause dangling
* pointers. ] * pointers. ]
* *
* <b>In even more detail, this is what happens when a SIGHUP * <b>In even more detail, this is what happens when a config read
* occurs:</b> * (like a SIGHUP or a SETCONF) occurs:</b>
* *
* We immediately destroy all unconfigured proxies (We shouldn't have * We immediately destroy all unconfigured proxies (We shouldn't have
* unconfigured proxies in the first place, except when SIGHUP rings * unconfigured proxies in the first place, except when the config
* immediately after tor is launched.). * read happens immediately after tor is launched.).
* *
* We mark all managed proxies and transports to signify that they * We mark all managed proxies and transports to signify that they
* must be removed if they don't contribute by the new torrc * must be removed if they don't contribute by the new torrc
* (we mark using the <b>marked_for_removal</b> element). * (we mark using the <b>marked_for_removal</b> element).
* We also mark all managed proxies to signify that they might need to * We also mark all managed proxies to signify that they might need to
* be restarted so that they end up supporting all the transports the * be restarted so that they end up supporting all the transports the
* new torrc wants them to support (using the <b>got_hup</b> element). * new torrc wants them to support
* (we mark using the <b>was_around_before_config_read</b> element).
* We also clear their <b>transports_to_launch</b> list so that we can * We also clear their <b>transports_to_launch</b> list so that we can
* put there the transports we need to launch according to the new * put there the transports we need to launch according to the new
* torrc. * torrc.
* *
* We then start parsing torrc again. * We then start parsing torrc again.
* *
* Everytime we encounter a transport line using a known pre-SIGHUP * Everytime we encounter a transport line using a managed proxy that
* managed proxy, we cleanse that proxy from the removal mark. * was around before the config read, we cleanse that proxy from the
* We also mark it as unconfigured so that on the next scheduled * removal mark. We also toggle the <b>check_if_restarts_needed</b>
* events tick, we investigate whether we need to restart the proxy * flag, so that on the next <b>pt_configure_remaining_proxies</b>
* so that it also spawns the new transports. * tick, we investigate whether we need to restart the proxy so that
* If the post-SIGHUP <b>transports_to_launch</b> list is identical to * it also spawns the new transports. If the post-config-read
* the pre-SIGHUP one, it means that no changes were introduced to * <b>transports_to_launch</b> list is identical to the pre-config-read
* this proxy during the SIGHUP and no restart has to take place. * one, it means that no changes were introduced to this proxy during
* the config read and no restart has to take place.
* *
* During the post-SIGHUP torrc parsing, we unmark all transports * During the post-config-read torrc parsing, we unmark all transports
* spawned by managed proxies that we find in our torrc. * spawned by managed proxies that we find in our torrc.
* We do that so that if we don't need to restart a managed proxy, we * We do that so that if we don't need to restart a managed proxy, we
* can continue using its old transports normally. * can continue using its old transports normally.
@ -1375,6 +1377,9 @@ pt_kickstart_proxy(const smartlist_t *transport_list,
check_if_restarts_needed = 1; check_if_restarts_needed = 1;
} }
/* For each new transport, check if the managed proxy used to
support it before the SIGHUP. If that was the case, make sure
it doesn't get removed because we might reuse it. */
SMARTLIST_FOREACH_BEGIN(transport_list, const char *, transport) { SMARTLIST_FOREACH_BEGIN(transport_list, const char *, transport) {
old_transport = transport_get_by_name(transport); old_transport = transport_get_by_name(transport);
if (old_transport) if (old_transport)