mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Merge remote-tracking branch 'public/bug10081'
This commit is contained in:
commit
24c4b56a39
5
changes/bug10081
Normal file
5
changes/bug10081
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
o Minor features:
|
||||||
|
- When reporting a failure from make_socket_reuseable(), don't
|
||||||
|
report a warning when we get a failure from an incoming socket
|
||||||
|
on OSX. Fix for bug 10081.
|
||||||
|
|
@ -958,8 +958,9 @@ check_location_for_unix_socket(const or_options_t *options, const char *path)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Tell the TCP stack that it shouldn't wait for a long time after
|
/** Tell the TCP stack that it shouldn't wait for a long time after
|
||||||
* <b>sock</b> has closed before reusing its port. */
|
* <b>sock</b> has closed before reusing its port. Return 0 on success,
|
||||||
static void
|
* -1 on failure. */
|
||||||
|
static int
|
||||||
make_socket_reuseable(tor_socket_t sock)
|
make_socket_reuseable(tor_socket_t sock)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -973,9 +974,9 @@ make_socket_reuseable(tor_socket_t sock)
|
|||||||
* already has it bound_. So, don't do that on Win32. */
|
* already has it bound_. So, don't do that on Win32. */
|
||||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &one,
|
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &one,
|
||||||
(socklen_t)sizeof(one)) == -1) {
|
(socklen_t)sizeof(one)) == -1) {
|
||||||
log_warn(LD_NET, "Error setting SO_REUSEADDR flag: %s",
|
return -1;
|
||||||
tor_socket_strerror(errno));
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1049,7 +1050,11 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
make_socket_reuseable(s);
|
if (make_socket_reuseable(s) < 0) {
|
||||||
|
log_warn(LD_NET, "Error setting SO_REUSEADDR flag on %s: %s",
|
||||||
|
conn_type_to_string(type),
|
||||||
|
tor_socket_strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
#if defined USE_TRANSPARENT && defined(IP_TRANSPARENT)
|
#if defined USE_TRANSPARENT && defined(IP_TRANSPARENT)
|
||||||
if (options->TransProxyType_parsed == TPT_TPROXY &&
|
if (options->TransProxyType_parsed == TPT_TPROXY &&
|
||||||
@ -1354,7 +1359,18 @@ connection_handle_listener_read(connection_t *conn, int new_type)
|
|||||||
"Connection accepted on socket %d (child of fd %d).",
|
"Connection accepted on socket %d (child of fd %d).",
|
||||||
(int)news,(int)conn->s);
|
(int)news,(int)conn->s);
|
||||||
|
|
||||||
make_socket_reuseable(news);
|
if (make_socket_reuseable(news) < 0) {
|
||||||
|
if (tor_socket_errno(news) == EINVAL) {
|
||||||
|
/* This can happen on OSX if we get a badly timed shutdown. */
|
||||||
|
log_debug(LD_NET, "make_socket_reuseable returned EINVAL");
|
||||||
|
} else {
|
||||||
|
log_warn(LD_NET, "Error setting SO_REUSEADDR flag on %s: %s",
|
||||||
|
conn_type_to_string(new_type),
|
||||||
|
tor_socket_strerror(errno));
|
||||||
|
}
|
||||||
|
tor_close_socket(news);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (options->ConstrainedSockets)
|
if (options->ConstrainedSockets)
|
||||||
set_constrained_socket_buffers(news, (int)options->ConstrainedSockSize);
|
set_constrained_socket_buffers(news, (int)options->ConstrainedSockSize);
|
||||||
@ -1563,7 +1579,10 @@ connection_connect(connection_t *conn, const char *address,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
make_socket_reuseable(s);
|
if (make_socket_reuseable(s) < 0) {
|
||||||
|
log_warn(LD_NET, "Error setting SO_REUSEADDR flag on new connection: %s",
|
||||||
|
tor_socket_strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
if (!tor_addr_is_loopback(addr)) {
|
if (!tor_addr_is_loopback(addr)) {
|
||||||
const tor_addr_t *ext_addr = NULL;
|
const tor_addr_t *ext_addr = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user