diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-07-31 13:51:15 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-07-31 13:51:15 -0400 |
commit | 904a58d10f144b95a689b35c88f6780371243da8 (patch) | |
tree | 174369db1cb98f3011124c306f3b06ae2b78b10d /src/or | |
parent | d5a5a6a2534e114b6c89c7ddb7840ab3040657b8 (diff) | |
parent | 8a0eedbbb08199818cd7c2c6998f062c03e33122 (diff) | |
download | tor-904a58d10f144b95a689b35c88f6780371243da8.tar.gz tor-904a58d10f144b95a689b35c88f6780371243da8.zip |
Merge branch 'bug9288_rebased'
Conflicts:
src/test/test_pt.c
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/statefile.c | 4 | ||||
-rw-r--r-- | src/or/statefile.h | 2 | ||||
-rw-r--r-- | src/or/transports.c | 28 | ||||
-rw-r--r-- | src/or/transports.h | 2 |
4 files changed, 21 insertions, 15 deletions
diff --git a/src/or/statefile.c b/src/or/statefile.c index bcb7b07417..aac8850b16 100644 --- a/src/or/statefile.c +++ b/src/or/statefile.c @@ -117,8 +117,8 @@ static const config_format_t state_format = { static or_state_t *global_state = NULL; /** Return the persistent state struct for this Tor. */ -or_state_t * -get_or_state(void) +MOCK_IMPL(or_state_t *, +get_or_state, (void)) { tor_assert(global_state); return global_state; diff --git a/src/or/statefile.h b/src/or/statefile.h index dcdee6c604..762b0f5ee1 100644 --- a/src/or/statefile.h +++ b/src/or/statefile.h @@ -7,7 +7,7 @@ #ifndef TOR_STATEFILE_H #define TOR_STATEFILE_H -or_state_t *get_or_state(void); +MOCK_DECL(or_state_t *,get_or_state,(void)); int did_last_state_file_write_fail(void); int or_state_save(time_t now); diff --git a/src/or/transports.c b/src/or/transports.c index 15faa98d40..62cc1a864f 100644 --- a/src/or/transports.c +++ b/src/or/transports.c @@ -103,8 +103,6 @@ create_managed_proxy_environment(const managed_proxy_t *mp); static INLINE int proxy_configuration_finished(const managed_proxy_t *mp); static void handle_finished_proxy(managed_proxy_t *mp); -static void configure_proxy(managed_proxy_t *mp); - static void parse_method_error(const char *line, int is_server_method); #define parse_server_method_error(l) parse_method_error(l, 1) #define parse_client_method_error(l) parse_method_error(l, 0) @@ -574,10 +572,8 @@ pt_configure_remaining_proxies(void) /* If the proxy is not fully configured, try to configure it futher. */ if (!proxy_configuration_finished(mp)) - configure_proxy(mp); - - if (proxy_configuration_finished(mp)) - at_least_a_proxy_config_finished = 1; + if (configure_proxy(mp) == 1) + at_least_a_proxy_config_finished = 1; } SMARTLIST_FOREACH_END(mp); @@ -589,10 +585,14 @@ pt_configure_remaining_proxies(void) mark_my_descriptor_dirty("configured managed proxies"); } -/** Attempt to continue configuring managed proxy <b>mp</b>. */ -static void +/** Attempt to continue configuring managed proxy <b>mp</b>. + * Return 1 if the transport configuration finished, and return 0 + * otherwise (if we still have more configuring to do for this + * proxy). */ +STATIC int configure_proxy(managed_proxy_t *mp) { + int configuration_finished = 0; smartlist_t *proxy_output = NULL; enum stream_status stream_status = 0; @@ -602,7 +602,7 @@ configure_proxy(managed_proxy_t *mp) mp->conf_state = PT_PROTO_FAILED_LAUNCH; handle_finished_proxy(mp); } - return; + return 0; } tor_assert(mp->conf_state != PT_PROTO_INFANT); @@ -634,13 +634,17 @@ configure_proxy(managed_proxy_t *mp) done: /* if the proxy finished configuring, exit the loop. */ - if (proxy_configuration_finished(mp)) + if (proxy_configuration_finished(mp)) { handle_finished_proxy(mp); + configuration_finished = 1; + } if (proxy_output) { SMARTLIST_FOREACH(proxy_output, char *, cp, tor_free(cp)); smartlist_free(proxy_output); } + + return configuration_finished; } /** Register server managed proxy <b>mp</b> transports to state */ @@ -709,7 +713,8 @@ managed_proxy_destroy(managed_proxy_t *mp, smartlist_free(mp->transports_to_launch); /* remove it from the list of managed proxies */ - smartlist_remove(managed_proxy_list, mp); + if (managed_proxy_list) + smartlist_remove(managed_proxy_list, mp); /* free the argv */ free_execve_args(mp->argv); @@ -746,7 +751,6 @@ handle_finished_proxy(managed_proxy_t *mp) } unconfigured_proxies_n--; - tor_assert(unconfigured_proxies_n >= 0); } /** Return true if the configuration of the managed proxy <b>mp</b> is diff --git a/src/or/transports.h b/src/or/transports.h index 1c6fc419b7..7b524f2073 100644 --- a/src/or/transports.h +++ b/src/or/transports.h @@ -121,6 +121,8 @@ STATIC void managed_proxy_destroy(managed_proxy_t *mp, STATIC managed_proxy_t *managed_proxy_create(const smartlist_t *transport_list, char **proxy_argv, int is_server); +STATIC int configure_proxy(managed_proxy_t *mp); + #endif #endif |