mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 02:09:24 +01:00
Merge remote-tracking branch 'public/bug9716_024' into maint-0.2.4
This commit is contained in:
commit
b4e8d8dc0e
4
changes/bug9716
Normal file
4
changes/bug9716
Normal file
@ -0,0 +1,4 @@
|
||||
o Bugfixes (performance):
|
||||
- Set the listen() backlog limit to the largest actually supported
|
||||
on the system, not to the value in a header file. Fixes bug 9716;
|
||||
bugfix on every released Tor.
|
@ -926,6 +926,27 @@ make_socket_reuseable(tor_socket_t sock)
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Max backlog to pass to listen. We start at */
|
||||
static int listen_limit = INT_MAX;
|
||||
|
||||
/* Listen on <b>fd</b> with appropriate backlog. Return as for listen. */
|
||||
static int
|
||||
tor_listen(tor_socket_t fd)
|
||||
{
|
||||
int r;
|
||||
|
||||
if ((r = listen(fd, listen_limit)) < 0) {
|
||||
if (listen_limit == SOMAXCONN)
|
||||
return r;
|
||||
if ((r = listen(fd, SOMAXCONN)) == 0) {
|
||||
listen_limit = SOMAXCONN;
|
||||
log_warn(LD_NET, "Setting listen backlog to INT_MAX connections "
|
||||
"didn't work, but SOMAXCONN did. Lowering backlog limit.");
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Bind a new non-blocking socket listening to the socket described
|
||||
* by <b>listensockaddr</b>.
|
||||
*
|
||||
@ -1009,7 +1030,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
||||
}
|
||||
|
||||
if (is_tcp) {
|
||||
if (listen(s,SOMAXCONN) < 0) {
|
||||
if (tor_listen(s) < 0) {
|
||||
log_warn(LD_NET, "Could not listen on %s:%u: %s", address, usePort,
|
||||
tor_socket_strerror(tor_socket_errno(s)));
|
||||
tor_close_socket(s);
|
||||
|
Loading…
Reference in New Issue
Block a user