Increase backlog for listening sockets 09/204809/1
authorDariusz Michaluk <d.michaluk@samsung.com>
Fri, 26 Apr 2019 12:18:41 +0000 (14:18 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Fri, 26 Apr 2019 12:18:41 +0000 (14:18 +0200)
When systemd's socket activaction is utilized, the default backlog
parameter passed to the listen() function is set to SOMAXCONN,
which is equal to 128. In distributions where systemd is not used
for socket activation, the default UNIX socket
implementation sets the backlog value to 5.
This may lead to rare overflow of an internal connection queue.
This manifests itself as the -EAGAIN error returned by connect().

To mitigate the issue, the backlog parameter has been set
to SOMAXCONN, which is a default value used by systemd.

Change-Id: I42b277d8d66c23335474fdf63db937ef22b8e171

src/server/main/socket-manager.cpp

index 4b8a7849ea68bd0e7b837e813f19d2f4f04b7c12..46b1822aa6709a028e95327ff1f299c8242f1939 100644 (file)
@@ -552,7 +552,7 @@ int SocketManager::CreateDomainSocketHelp(
 
     umask(originalUmask);
 
-    if (-1 == listen(sockfd, 5)) {
+    if (-1 == listen(sockfd, SOMAXCONN)) {
         int err = errno;
         close(sockfd);
         LogError("Error in listen: " << GetErrnoString(err));