MXS-975: Remove hard limit on listen backlog

The listen() backlog is now set to INT_MAX which should guarantee that the
internal limit is always higher than the system limit. This means that the
length of the queue always follows /proc/sys/net/ipv4/tcp_max_syn_backlog.
This commit is contained in:
Markus Makela
2016-11-16 11:41:14 +02:00
parent a7c21eee88
commit b594bdc42a
2 changed files with 16 additions and 1 deletions

View File

@ -723,6 +723,14 @@ This example configuration requires all connections to this server to be encrypt
The listener defines a port and protocol pair that is used to listen for connections to a service. A service may have multiple listeners associated with it, either to support multiple protocols or multiple ports. As with other elements of the configuration the section name is the listener name and it can be selected freely. A type parameter is used to identify the section as a listener definition. Address is optional and it allows the user to limit connections to certain interface only. Socket is also optional and used for Unix socket connections. The listener defines a port and protocol pair that is used to listen for connections to a service. A service may have multiple listeners associated with it, either to support multiple protocols or multiple ports. As with other elements of the configuration the section name is the listener name and it can be selected freely. A type parameter is used to identify the section as a listener definition. Address is optional and it allows the user to limit connections to certain interface only. Socket is also optional and used for Unix socket connections.
The network socket where the listener listens will have a backlog of
connections. The size of this backlog is controlled by the
net.ipv4.tcp_max_syn_backlog and net.core.somaxconn kernel parameters.
Increasing the size of the backlog by modifying the kernel parameters
helps with sudden connection spikes and rejected connections. For more
information see [listen(2)](http://man7.org/linux/man-pages/man2/listen.2.html).
``` ```
[<Listener name>] [<Listener name>]
type=listener type=listener

View File

@ -3497,7 +3497,14 @@ dcb_listen(DCB *listener, const char *config, const char *protocol_name)
return -1; return -1;
} }
if (listen(listener_socket, 10 * SOMAXCONN) != 0) /**
* The use of INT_MAX for backlog length in listen() allows the end-user to
* control the backlog length with the net.ipv4.tcp_max_syn_backlog kernel
* option since the parameter is silently truncated to the configured value.
*
* @see man 2 listen
*/
if (listen(listener_socket, INT_MAX) != 0)
{ {
char errbuf[STRERROR_BUFLEN]; char errbuf[STRERROR_BUFLEN];
MXS_ERROR("Failed to start listening on '%s' with protocol '%s': %d, %s", MXS_ERROR("Failed to start listening on '%s' with protocol '%s': %d, %s",