Rename the got_hup element of managed proxies.

Since we need to toggle that element in non-SIGHUP situations too where
the config was re-read (like in SETCONF or RESETCONF).
This commit is contained in:
George Kadianakis 2014-04-08 17:22:36 +01:00 committed by Nick Mathewson
parent bf7cb6acf6
commit fa0c5da68b
2 changed files with 15 additions and 14 deletions

View file

@ -554,11 +554,12 @@ pt_configure_remaining_proxies(void)
tor_assert(mp->conf_state != PT_PROTO_BROKEN && tor_assert(mp->conf_state != PT_PROTO_BROKEN &&
mp->conf_state != PT_PROTO_FAILED_LAUNCH); mp->conf_state != PT_PROTO_FAILED_LAUNCH);
if (mp->got_hup) { if (mp->was_around_before_config_read) {
mp->got_hup = 0; /* This proxy is marked by a config read. Check whether we need
to restart it. */
mp->was_around_before_config_read = 0;
/* This proxy is marked by a SIGHUP. Check whether we need to
restart it. */
if (proxy_needs_restart(mp)) { if (proxy_needs_restart(mp)) {
log_info(LD_GENERAL, "Preparing managed proxy '%s' for restart.", log_info(LD_GENERAL, "Preparing managed proxy '%s' for restart.",
mp->argv[0]); mp->argv[0]);
@ -1363,14 +1364,12 @@ pt_kickstart_proxy(const smartlist_t *transport_list,
managed_proxy_create(transport_list, proxy_argv, is_server); managed_proxy_create(transport_list, proxy_argv, is_server);
} else { /* known proxy. add its transport to its transport list */ } else { /* known proxy. add its transport to its transport list */
if (mp->got_hup) { if (mp->was_around_before_config_read) {
/* If the managed proxy we found is marked by a SIGHUP, it means /* If this managed proxy was around even before we read the
that it's not useless and should be kept. If it's marked for config this time, it means that it was already enabled before
removal, unmark it and increase the unconfigured proxies so and is not useless and should be kept. If it's marked for
that we try to restart it if we need to. Afterwards, check if removal, unmark it and make sure that we check whether it
a transport_t for 'transport' used to exist before the SIGHUP needs to be restarted. */
and make sure it doesn't get deleted because we might reuse
it. */
if (mp->marked_for_removal) { if (mp->marked_for_removal) {
mp->marked_for_removal = 0; mp->marked_for_removal = 0;
check_if_restarts_needed = 1; check_if_restarts_needed = 1;
@ -1424,8 +1423,10 @@ pt_prepare_proxy_list_for_config_read(void)
tor_assert(mp->conf_state == PT_PROTO_COMPLETED); tor_assert(mp->conf_state == PT_PROTO_COMPLETED);
/* Mark all proxies for removal, and also note that they have been
here before the config read. */
mp->marked_for_removal = 1; mp->marked_for_removal = 1;
mp->got_hup = 1; mp->was_around_before_config_read = 1;
SMARTLIST_FOREACH(mp->transports_to_launch, char *, t, tor_free(t)); SMARTLIST_FOREACH(mp->transports_to_launch, char *, t, tor_free(t));
smartlist_clear(mp->transports_to_launch); smartlist_clear(mp->transports_to_launch);
} SMARTLIST_FOREACH_END(mp); } SMARTLIST_FOREACH_END(mp);

View file

@ -97,7 +97,7 @@ typedef struct {
* this flag to signify that this proxy might need to be restarted * this flag to signify that this proxy might need to be restarted
* so that it can listen for other transports according to the new * so that it can listen for other transports according to the new
* torrc. */ * torrc. */
unsigned int got_hup : 1; unsigned int was_around_before_config_read : 1;
/* transports to-be-launched by this proxy */ /* transports to-be-launched by this proxy */
smartlist_t *transports_to_launch; smartlist_t *transports_to_launch;