aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-01-17 12:04:53 -0500
committerNick Mathewson <nickm@torproject.org>2014-01-17 12:04:53 -0500
commit85b46d57bcc40b8053dafe5d0ebb4b0bb611b484 (patch)
treecbf0ab74e061e7815d51f400e8b6cc19158dc80d /src
parent35115496511f64c08849a039c926910739467169 (diff)
downloadtor-85b46d57bcc40b8053dafe5d0ebb4b0bb611b484.tar
tor-85b46d57bcc40b8053dafe5d0ebb4b0bb611b484.tar.gz
Check spawn_func() return value
If we don't, we can wind up with a wedged cpuworker, and write to it for ages and ages. Found by skruffy. This was a bug in 2dda97e8fd898757, a.k.a. svn revision 402. It's been there since we have been using cpuworkers.
Diffstat (limited to 'src')
-rw-r--r--src/or/cpuworker.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index ecf0d2035..2f9f527e9 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -528,7 +528,12 @@ spawn_cpuworker(void)
tor_assert(SOCKET_OK(fdarray[1]));
fd = fdarray[0];
- spawn_func(cpuworker_main, (void*)fdarray);
+ if (spawn_func(cpuworker_main, (void*)fdarray) < 0) {
+ tor_close_socket(fdarray[0]);
+ tor_close_socket(fdarray[1]);
+ tor_free(fdarray);
+ return -1;
+ }
log_debug(LD_OR,"just spawned a cpu worker.");
#ifndef TOR_IS_MULTITHREADED
tor_close_socket(fdarray[1]); /* don't need the worker's side of the pipe */