[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Refrain from compiling socket rebinding code on system that don't need it
commit f04e0bd5d630a2ef3b618f3fe6f05d46358dfb65
Author: rl1987 <rl1987@xxxxxxxxxxxxxxxx>
Date: Wed Apr 25 17:27:06 2018 +0200
Refrain from compiling socket rebinding code on system that don't need it
---
src/core/mainloop/connection.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index 22fa3fb79..9725c3030 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. */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits