mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Fix some bugs that did not allow compilation on Windows.
This commit is contained in:
parent
44fe717524
commit
b9551fd074
@ -4381,17 +4381,17 @@ tor_get_lines_from_handle(HANDLE *handle,
|
||||
char stdout_buf[600] = {0};
|
||||
smartlist_t *lines = NULL;
|
||||
|
||||
tor_assert(stream_status);
|
||||
tor_assert(stream_status_out);
|
||||
|
||||
*stream_status = IO_STREAM_TERM;
|
||||
*stream_status_out = IO_STREAM_TERM;
|
||||
|
||||
pos = tor_read_all_handle(handle, stdout_buf, sizeof(stdout_buf) - 1, NULL);
|
||||
if (pos < 0) {
|
||||
*stream_status = IO_STREAM_TERM;
|
||||
*stream_status_out = IO_STREAM_TERM;
|
||||
return NULL;
|
||||
}
|
||||
if (pos == 0) {
|
||||
*stream_status = IO_STREAM_EAGAIN;
|
||||
*stream_status_out = IO_STREAM_EAGAIN;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -4408,7 +4408,7 @@ tor_get_lines_from_handle(HANDLE *handle,
|
||||
SMARTLIST_FOREACH(lines, char *, line,
|
||||
SMARTLIST_REPLACE_CURRENT(lines, line, tor_strdup(line)));
|
||||
|
||||
*stream_status = IO_STREAM_OKAY;
|
||||
*stream_status_out = IO_STREAM_OKAY;
|
||||
|
||||
return lines;
|
||||
}
|
||||
@ -4461,8 +4461,8 @@ log_from_handle(HANDLE *pipe, int severity)
|
||||
#else
|
||||
|
||||
/** Return a smartlist containing lines outputted from
|
||||
* <b>handle</b>. Return NULL on error, and set <b>stream_status</b>
|
||||
* appropriately. */
|
||||
* <b>handle</b>. Return NULL on error, and set
|
||||
* <b>stream_status_out</b> appropriately. */
|
||||
smartlist_t *
|
||||
tor_get_lines_from_handle(FILE *handle, enum stream_status *stream_status_out)
|
||||
{
|
||||
|
@ -353,28 +353,18 @@ parse_port(const char *arg)
|
||||
/** Report a failure of epic proportions: We didn't manage to
|
||||
* initialize any port forwarding backends. */
|
||||
static void
|
||||
report_full_fail(const smartlist_t *ports_to_forward, backends_t *backends)
|
||||
report_full_fail(const smartlist_t *ports_to_forward)
|
||||
{
|
||||
char *list_of_backends_str = NULL;
|
||||
char *fail_msg = NULL;
|
||||
|
||||
if (!ports_to_forward)
|
||||
return;
|
||||
|
||||
list_of_backends_str = get_list_of_backends_string(backends);
|
||||
tor_asprintf(&fail_msg,
|
||||
"Port forwarding backends (%s) could not be initialized.",
|
||||
list_of_backends_str);
|
||||
|
||||
SMARTLIST_FOREACH_BEGIN(ports_to_forward,
|
||||
const port_to_forward_t *, port_to_forward) {
|
||||
tor_fw_helper_report_port_fw_fail(port_to_forward->internal_port,
|
||||
port_to_forward->external_port,
|
||||
fail_msg);
|
||||
"All backends (NAT-PMP, UPnP) failed "
|
||||
"to initialize!"); /* XXX hardcoded */
|
||||
} SMARTLIST_FOREACH_END(port_to_forward);
|
||||
|
||||
tor_free(list_of_backends_str);
|
||||
tor_free(fail_msg);
|
||||
}
|
||||
|
||||
int
|
||||
@ -481,8 +471,8 @@ main(int argc, char **argv)
|
||||
r = init_backends(&tor_fw_options, &backend_state);
|
||||
if (!r) { // all backends failed:
|
||||
// report our failure
|
||||
report_full_fail(tor_fw_options.ports_to_forward, &backend_state);
|
||||
fprintf(stderr, "V: tor-fw-helper: All backends failed.\n");
|
||||
report_full_fail(tor_fw_options.ports_to_forward);
|
||||
fprintf(stderr, "tor-fw-helper: All backends failed.\n");
|
||||
exit(1);
|
||||
} else { // some backends succeeded:
|
||||
fprintf(stderr, "tor-fw-helper: %i NAT traversal helper(s) loaded\n", r);
|
||||
|
Loading…
Reference in New Issue
Block a user