summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2021-09-24 16:08:12 +0200
committerDavid Goulet <dgoulet@torproject.org>2023-05-25 10:50:11 -0400
commit506781d41e9b0943c3c8a9670011f9309f159cb4 (patch)
tree0942ceddc8844ba54a9ab928b6b2ba1a01fa9aaa
parent58f0e548fff20648d848ed95c1daa2f071ef0743 (diff)
downloadtor-506781d41e9b0943c3c8a9670011f9309f159cb4.tar.gz
tor-506781d41e9b0943c3c8a9670011f9309f159cb4.zip
Restart PT processes when they die on us.
This patch forces a PT reconfigure of infant PT processes as part of the PT process' exit handler. See: tpo/core/tor#33669
-rw-r--r--src/feature/client/transports.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/feature/client/transports.c b/src/feature/client/transports.c
index ceeae61dd4..cac7e694c7 100644
--- a/src/feature/client/transports.c
+++ b/src/feature/client/transports.c
@@ -556,6 +556,8 @@ launch_managed_proxy(managed_proxy_t *mp)
smartlist_t *env = create_managed_proxy_environment(mp);
/* Configure our process. */
+ tor_assert(mp->process == NULL);
+ mp->process = process_new(mp->argv[0]);
process_set_data(mp->process, mp);
process_set_stdout_read_callback(mp->process, managed_proxy_stdout_callback);
process_set_stderr_read_callback(mp->process, managed_proxy_stderr_callback);
@@ -1532,7 +1534,9 @@ managed_proxy_create(const smartlist_t *with_transport_list,
mp->argv = proxy_argv;
mp->transports = smartlist_new();
mp->proxy_uri = get_pt_proxy_uri();
- mp->process = process_new(proxy_argv[0]);
+
+ /* Gets set in launch_managed_proxy(). */
+ mp->process = NULL;
mp->transports_to_launch = smartlist_new();
SMARTLIST_FOREACH(with_transport_list, const char *, transport,
@@ -1943,13 +1947,25 @@ managed_proxy_exit_callback(process_t *process, process_exit_code_t exit_code)
{
tor_assert(process);
- const managed_proxy_t *mp = process_get_data(process);
+ managed_proxy_t *mp = process_get_data(process);
const char *name = mp ? mp->argv[0] : "N/A";
log_warn(LD_PT,
"Managed proxy \"%s\" process terminated with status code %" PRIu64,
name, exit_code);
+ if (mp) {
+ /* We remove this process_t from the mp. */
+ tor_assert(mp->process == process);
+ mp->process = NULL;
+
+ /* Prepare the proxy for restart. */
+ proxy_prepare_for_restart(mp);
+
+ /* We have proxies we want to restart? */
+ pt_configure_remaining_proxies();
+ }
+
/* Returning true here means that the process subsystem will take care of
* calling process_free() on our process_t. */
return true;