|
@@ -5156,51 +5156,6 @@ tor_get_lines_from_handle, (HANDLE *handle,
|
|
|
return lines;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * Returns -1 if there is a error reading, and 0 otherwise.
|
|
|
- * If the generated stream is flushed more often than on new lines, or
|
|
|
- * a read exceeds 256 bytes, lines will be truncated. This should be fixed,
|
|
|
- * along with the corresponding problem on *nix (see bug #2045).
|
|
|
- */
|
|
|
-static int
|
|
|
-log_from_handle(HANDLE *pipe, int severity)
|
|
|
-{
|
|
|
- char buf[256];
|
|
|
- int pos;
|
|
|
- smartlist_t *lines;
|
|
|
-
|
|
|
- pos = tor_read_all_handle(pipe, buf, sizeof(buf) - 1, NULL);
|
|
|
- if (pos < 0) {
|
|
|
-
|
|
|
- log_warn(LD_GENERAL, "Failed to read data from subprocess");
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- if (0 == pos) {
|
|
|
-
|
|
|
- log_debug(LD_GENERAL, "Subprocess had nothing to say");
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- buf[pos] = '\0';
|
|
|
- log_debug(LD_GENERAL, "Subprocess had %d bytes to say", pos);
|
|
|
-
|
|
|
-
|
|
|
- lines = smartlist_new();
|
|
|
- tor_split_lines(lines, buf, pos);
|
|
|
-
|
|
|
-
|
|
|
- SMARTLIST_FOREACH(lines, char *, line,
|
|
|
- {
|
|
|
- log_fn(severity, LD_GENERAL, "Port forwarding helper says: %s", line);
|
|
|
- });
|
|
|
- smartlist_free(lines);
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
#else
|
|
|
|
|
|
|