tor_addr_t addr;
int exhaustion = 0;
- if (addr_in_use) *addr_in_use = 0;
+ if (addr_in_use)
+ *addr_in_use = 0;
if (listensockaddr->sa_family == AF_INET ||
listensockaddr->sa_family == AF_INET6) {
int e = tor_socket_errno(s);
if (ERRNO_IS_EADDRINUSE(e)) {
helpfulhint = ". Is Tor already running?";
- if (addr_in_use) *addr_in_use = 1;
+ if (addr_in_use)
+ *addr_in_use = 1;
}
log_warn(LD_NET, "Could not bind to %s:%u: %s%s", address, usePort,
tor_socket_strerror(e), helpfulhint);
*defer = 0;
if (port->server_cfg.no_listen) {
- if (defer) *defer = 1;
+ if (defer)
+ *defer = 1;
return NULL;
}
const or_options_t *options = get_options();
if (port->is_unix_addr && !geteuid() && (options->User) &&
strcmp(options->User, "root")) {
- if (defer) *defer = 1;
+ if (defer)
+ *defer = 1;
return NULL;
}
#endif /* !defined(_WIN32) */
return ret;
}
-struct replacement_s
-{
- connection_t *old_conn;
- port_cfg_t *new_port;
-};
-
/** Given a list of listener connections in <b>old_conns</b>, and list of
* port_cfg_t entries in <b>ports</b>, open a new listener for every port in
* <b>ports</b> that does not already have a listener in <b>old_conns</b>.
* Remove from <b>old_conns</b> every connection that has a corresponding
* entry in <b>ports</b>. Add to <b>new_conns</b> new every connection we
* launch. If we may need to perform socket rebind when creating new
- * listener that replaces old one, create a <b>replacement_s</b> struct
- * for affected pair and add it to <b>replacements</b>. For more
+ * listener that replaces old one, create a <b>listener_replacement_t</b>
+ * struct for affected pair and add it to <b>replacements</b>. For more
* information, see ticket #17873.
*
* If <b>control_listeners_only</b> is true, then we only open control
port_matches_exact && bool_neq(tor_addr_is_null(&wanted->addr),
tor_addr_is_null(&conn->addr));
if (replacements && may_need_rebind) {
- struct replacement_s *replacement =
- tor_malloc(sizeof(struct replacement_s));
+ listener_replacement_t *replacement =
+ tor_malloc(sizeof(listener_replacement_t));
replacement->old_conn = conn;
- replacement->new_port = (port_cfg_t *)wanted;
+ replacement->new_port = wanted;
smartlist_add(replacements, replacement);
SMARTLIST_DEL_CURRENT(launch, wanted);
retval = -1;
#ifdef ENABLE_LISTENER_REBIND
- SMARTLIST_FOREACH_BEGIN(replacements, struct replacement_s *, r) {
+ SMARTLIST_FOREACH_BEGIN(replacements, listener_replacement_t *, r) {
int addr_in_use = 0;
int skip = 0;
/** State for any listener connection. */
#define LISTENER_STATE_READY 0
+/**
+ * This struct associates an old listener connection to be replaced
+ * by new connection described by port configuration. Only used when
+ * moving listeners to/from wildcard IP address.
+ */
+typedef struct
+{
+ connection_t *old_conn; /* Old listener connection to be replaced */
+ const port_cfg_t *new_port; /* New port configuration */
+} listener_replacement_t;
+
const char *conn_type_to_string(int type);
const char *conn_state_to_string(int type, int state);
int conn_listener_type_supports_af_unix(int type);