summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-04 18:06:17 +0200
committerSimon McVittie <smcv@debian.org>2017-08-15 11:53:16 -0400
commita8dc1ebdaec43b175c831a944933c2170b6eaaea (patch)
treec0f6fe30987fdbcab7cb3755ffdcb5c5d2fe2451
parent3cf2d6a1ca43253e5be916b8cfa30fd9ba1a2ef0 (diff)
downloaddbus-a8dc1ebdaec43b175c831a944933c2170b6eaaea.tar.gz
sysdeps: increase listen() backlog of AF_UNIX sockets to SOMAXCONN
Previously, the listen() backlog was set to an arbitrary 30. This means that if dbus-daemon is overloaded only 30 more connections may be queued by the kernel, before connect() fails with EAGAIN. (Note that EAGAIN != EINPROGRESS -- the latter is what is returned if a connection is queued and being processed for asynchronous sockets; EAGAIN in this case is really an error, that cannot be recovered from). Most software simply sets SOMAXCONN as backlog for AF_UNIX sockets, to allow queuing of as many connections as the kernel allows. SOMAXCONN is 128 on Linux, which is not particularly high, but at least higher than 30. This patch changes dbus-daemon to do the same. I noticed this when flooding dbus-daemon with a lot of connections, where it pretty quickly ceased to respond, much earlier than it really should. Note that the backlog has nothing to do with the number of concurrent connections allowed, it simply controls how many queued, but not accept()ed connections there may be on the listening socket. (cherry picked from commit 12bd6e893c91430fdbdf8a27087d4a792b04eef9) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95264 Bug-Debian: https://bugs.debian.org/872144 Reviewed-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Thiago Macieira <thiago@kde.org>
-rw-r--r--dbus/dbus-sysdeps-unix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 9d914f8c..b7a26507 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1195,7 +1195,7 @@ _dbus_listen_unix_socket (const char *path,
return -1;
}
- if (listen (listen_fd, 30 /* backlog */) < 0)
+ if (listen (listen_fd, SOMAXCONN /* backlog */) < 0)
{
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to listen on socket \"%s\": %s",