From 4b266c6e72254d848b2ca4f594c0b41770104d81 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Sun, 15 May 2011 08:23:04 -0700 Subject: Implement __OwningControllerProcess option Implements part of feature 3049. --- src/or/control.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/or/control.h') diff --git a/src/or/control.h b/src/or/control.h index 2ae96b4b8a..81c23010d2 100644 --- a/src/or/control.h +++ b/src/or/control.h @@ -70,6 +70,8 @@ smartlist_t *decode_hashed_passwords(config_line_t *passwords); void disable_control_logging(void); void enable_control_logging(void); +int monitor_owning_controller_process(const char *process_spec); + void control_event_bootstrap(bootstrap_status_t status, int progress); void control_event_bootstrap_problem(const char *warn, int reason); -- cgit v1.2.3-54-g00ecf From b3133d1cadec0540105a855b1fd2eb741d4eec9d Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Mon, 16 May 2011 10:25:59 -0700 Subject: Exit immediately if we can't monitor our owning controller process tor_process_monitor_new can't currently return NULL, but if it ever can, we want that to be an explicitly fatal error, without relying on the fact that monitor_owning_controller_process's chain of caller will exit if it fails. --- src/or/config.c | 5 +---- src/or/control.c | 20 ++++++++++---------- src/or/control.h | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src/or/control.h') diff --git a/src/or/config.c b/src/or/config.c index b2bc9f3e9a..0d1c37f6b6 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1232,10 +1232,7 @@ options_act(or_options_t *old_options) return -1; } - if (monitor_owning_controller_process(options->OwningControllerProcess)) { - log_warn(LD_CONFIG, "Error monitoring owning controller process"); - return -1; - } + monitor_owning_controller_process(options->OwningControllerProcess); /* reload keys as needed for rendezvous services. */ if (rend_service_load_keys()<0) { diff --git a/src/or/control.c b/src/or/control.c index 3a96904438..67e8b00d19 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -3815,8 +3815,8 @@ owning_controller_procmon_cb(void *unused) } /** Set process_spec as Tor's owning controller process. - * Return 0 on success, -1 on failure. */ -int + * Exit on failure. */ +void monitor_owning_controller_process(const char *process_spec) { const char *msg; @@ -3829,7 +3829,7 @@ monitor_owning_controller_process(const char *process_spec) owning_controller_process_spec)) { /* Same process -- return now, instead of disposing of and * recreating the process-termination monitor. */ - return 0; + return; } /* We are currently owned by a process, and we should no longer be @@ -3845,7 +3845,7 @@ monitor_owning_controller_process(const char *process_spec) (owning_controller_process_monitor == NULL)); if (process_spec == NULL) - return 0; + return; owning_controller_process_spec = tor_strdup(process_spec); owning_controller_process_monitor = @@ -3856,13 +3856,13 @@ monitor_owning_controller_process(const char *process_spec) &msg); if (owning_controller_process_monitor == NULL) { - log_warn(LD_CONTROL, "Couldn't create process-termination monitor for " - "owning controller: %s", - msg); - return -1; + log_err(LD_BUG, "Couldn't create process-termination monitor for " + "owning controller: %s. Exiting.", + msg); + owning_controller_process_spec = NULL; + tor_cleanup(); + exit(0); } - - return 0; } /** Convert the name of a bootstrapping phase s into strings diff --git a/src/or/control.h b/src/or/control.h index 81c23010d2..a83e3747e6 100644 --- a/src/or/control.h +++ b/src/or/control.h @@ -70,7 +70,7 @@ smartlist_t *decode_hashed_passwords(config_line_t *passwords); void disable_control_logging(void); void enable_control_logging(void); -int monitor_owning_controller_process(const char *process_spec); +void monitor_owning_controller_process(const char *process_spec); void control_event_bootstrap(bootstrap_status_t status, int progress); void control_event_bootstrap_problem(const char *warn, int reason); -- cgit v1.2.3-54-g00ecf From 338a0266101e3addecbaf5771f62a860244896b3 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Thu, 19 May 2011 16:27:51 -0700 Subject: Split control connection cleanup out of connection_free --- src/or/connection.c | 3 +-- src/or/control.c | 10 ++++++++++ src/or/control.h | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/or/control.h') diff --git a/src/or/connection.c b/src/or/connection.c index fc2097f9a9..24ab593fef 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -479,8 +479,7 @@ connection_free(connection_t *conn) } } if (conn->type == CONN_TYPE_CONTROL) { - TO_CONTROL_CONN(conn)->event_mask = 0; - control_update_global_event_mask(); + connection_control_closed(TO_CONTROL_CONN(conn)); } connection_unregister_events(conn); _connection_free(conn); diff --git a/src/or/control.c b/src/or/control.c index 47e7081825..0ddbee99c1 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2739,6 +2739,16 @@ connection_control_reached_eof(control_connection_t *conn) return 0; } +/** Called when conn is being freed. */ +void +connection_control_closed(control_connection_t *conn) +{ + tor_assert(conn); + + conn->event_mask = 0; + control_update_global_event_mask(); +} + /** Return true iff cmd is allowable (or at least forgivable) at this * stage of the protocol. */ static int diff --git a/src/or/control.h b/src/or/control.h index a83e3747e6..6694c96438 100644 --- a/src/or/control.h +++ b/src/or/control.h @@ -25,6 +25,8 @@ void control_adjust_event_log_severity(void); int connection_control_finished_flushing(control_connection_t *conn); int connection_control_reached_eof(control_connection_t *conn); +void connection_control_closed(control_connection_t *conn); + int connection_control_process_inbuf(control_connection_t *conn); #define EVENT_AUTHDIR_NEWDESCS 0x000D -- cgit v1.2.3-54-g00ecf