Increase backlog for listening sockets 38/206138/1
authorDariusz Michaluk <d.michaluk@samsung.com>
Tue, 14 May 2019 13:53:58 +0000 (15:53 +0200)
committerDariusz Michaluk <d.michaluk@samsung.com>
Tue, 14 May 2019 13:53:58 +0000 (15:53 +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: I906cd4de478b0dac0eaf860550fccd2f9cd6e184

src/manager/main/socket-manager.cpp

index f3f6e3f..07ce31c 100644 (file)
@@ -617,7 +617,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));