aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-05-06 21:22:40 -0400
committerNick Mathewson <nickm@torproject.org>2014-05-06 21:22:40 -0400
commit1adc98b9b55a28a6785a6faf8e5b3369981d8dbb (patch)
tree2c6b0a41b9362447396d2f413e2cedeb737bb589 /src/common
parentba5069b3101c24f53718d20c2e267e07509ace03 (diff)
downloadtor-1adc98b9b55a28a6785a6faf8e5b3369981d8dbb.tar
tor-1adc98b9b55a28a6785a6faf8e5b3369981d8dbb.tar.gz
Split portfw-error-logging code into a new function.
No code has changed; only moved. Part of a fix for 9781.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 6524be3ed..d82677d5a 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -4540,6 +4540,30 @@ stream_status_to_string(enum stream_status stream_status)
}
}
+/* DOCDOC */
+static void
+log_portfw_spawn_error_message(const char *buf,
+ const char *executable, int *child_status)
+{
+ /* Parse error message */
+ int retval, child_state, saved_errno;
+ retval = tor_sscanf(buf, SPAWN_ERROR_MESSAGE "%x/%x",
+ &child_state, &saved_errno);
+ if (retval == 2) {
+ log_warn(LD_GENERAL,
+ "Failed to start child process \"%s\" in state %d: %s",
+ executable, child_state, strerror(saved_errno));
+ if (child_status)
+ *child_status = 1;
+ } else {
+ /* Failed to parse message from child process, log it as a
+ warning */
+ log_warn(LD_GENERAL,
+ "Unexpected message from port forwarding helper \"%s\": %s",
+ executable, buf);
+ }
+}
+
#ifdef _WIN32
/** Return a smartlist containing lines outputted from
@@ -4687,23 +4711,7 @@ log_from_pipe(FILE *stream, int severity, const char *executable,
/* Check if buf starts with SPAWN_ERROR_MESSAGE */
if (strcmpstart(buf, SPAWN_ERROR_MESSAGE) == 0) {
- /* Parse error message */
- int retval, child_state, saved_errno;
- retval = tor_sscanf(buf, SPAWN_ERROR_MESSAGE "%x/%x",
- &child_state, &saved_errno);
- if (retval == 2) {
- log_warn(LD_GENERAL,
- "Failed to start child process \"%s\" in state %d: %s",
- executable, child_state, strerror(saved_errno));
- if (child_status)
- *child_status = 1;
- } else {
- /* Failed to parse message from child process, log it as a
- warning */
- log_warn(LD_GENERAL,
- "Unexpected message from port forwarding helper \"%s\": %s",
- executable, buf);
- }
+ log_portfw_spawn_error_message(buf, executable, child_status);
} else {
log_fn(severity, LD_GENERAL, "Port forwarding helper says: %s", buf);
}