diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2018-04-25 17:27:06 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-12 09:05:39 -0400 |
commit | f04e0bd5d630a2ef3b618f3fe6f05d46358dfb65 (patch) | |
tree | 7397f98849fe64fb67308e0f3c09fc0193470e25 /src/core | |
parent | c99bb8b6ea2b533e8ed99e6a41d74fc3bbeddb94 (diff) | |
download | tor-f04e0bd5d630a2ef3b618f3fe6f05d46358dfb65.tar.gz tor-f04e0bd5d630a2ef3b618f3fe6f05d46358dfb65.zip |
Refrain from compiling socket rebinding code on system that don't need it
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/mainloop/connection.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index 22fa3fb795..9725c3030a 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -133,6 +133,10 @@ #include "feature/nodelist/routerinfo_st.h" #include "core/or/socks_request_st.h" +#if defined(__linux__) || defined(_WIN32) +#define ENABLE_LISTENER_REBIND +#endif + static connection_t *connection_listener_new( const struct sockaddr *listensockaddr, socklen_t listensocklen, int type, @@ -1517,7 +1521,7 @@ connection_listener_new_for_port(const port_cfg_t *port, *defer = 0; if (port->server_cfg.no_listen) { - *defer = 1; + if (defer) *defer = 1; return NULL; } @@ -1527,7 +1531,7 @@ connection_listener_new_for_port(const port_cfg_t *port, const or_options_t *options = get_options(); if (port->is_unix_addr && !geteuid() && (options->User) && strcmp(options->User, "root")) { - *defer = 1; + if (defer) *defer = 1; return NULL; } #endif /* !defined(_WIN32) */ @@ -2698,6 +2702,9 @@ retry_listener_ports(smartlist_t *old_conns, smartlist_t *replacements, int control_listeners_only) { +#ifndef ENABLE_LISTENER_REBIND + (void)replacements; +#endif smartlist_t *launch = smartlist_new(); int r = 0; @@ -2746,6 +2753,7 @@ retry_listener_ports(smartlist_t *old_conns, found_port = wanted; break; } +#ifdef ENABLE_LISTENER_REBIND const int may_need_rebind = port_matches_exact && bool_neq(tor_addr_is_null(&wanted->addr), tor_addr_is_null(&conn->addr)); @@ -2758,7 +2766,9 @@ retry_listener_ports(smartlist_t *old_conns, smartlist_add(replacements, replacement); SMARTLIST_DEL_CURRENT(launch, wanted); + SMARTLIST_DEL_CURRENT(old_conns, conn); } +#endif } } SMARTLIST_FOREACH_END(wanted); @@ -2823,6 +2833,7 @@ retry_all_listeners(smartlist_t *replaced_conns, close_all_noncontrol) < 0) retval = -1; +#ifdef ENABLE_LISTENER_REBIND SMARTLIST_FOREACH_BEGIN(replacements, struct replacement_s *, r) { int addr_in_use = 0; int skip = 0; @@ -2854,6 +2865,7 @@ retry_all_listeners(smartlist_t *replaced_conns, tor_free(r); SMARTLIST_DEL_CURRENT(replacements, r); } SMARTLIST_FOREACH_END(r); +#endif /* Any members that were still in 'listeners' don't correspond to * any configured port. Kill 'em. */ |