mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-07 07:28:01 +02:00
Disable slow-start on TCP sockets
Leaving Nagle's algorithm enabled on the TCP transport leads to some really long latencies (at least, during the first several messages). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=75544 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
This commit is contained in:
parent
e2bd0b1317
commit
dd4e09339f
1 changed files with 11 additions and 1 deletions
|
|
@ -53,6 +53,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netdb.h>
|
||||
#include <grp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
|
@ -1395,7 +1396,7 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
tmp = ai;
|
||||
while (tmp)
|
||||
{
|
||||
int fd = -1, *newlisten_fd;
|
||||
int fd = -1, *newlisten_fd, tcp_nodelay_on;
|
||||
if (!_dbus_open_socket (&fd, tmp->ai_family, SOCK_STREAM, 0, error))
|
||||
{
|
||||
_DBUS_ASSERT_ERROR_IS_SET(error);
|
||||
|
|
@ -1410,6 +1411,15 @@ _dbus_listen_tcp_socket (const char *host,
|
|||
host ? host : "*", port, _dbus_strerror (errno));
|
||||
}
|
||||
|
||||
/* Nagle's algorithm imposes a huge delay on the initial messages
|
||||
going over TCP. */
|
||||
tcp_nodelay_on = 1;
|
||||
if (setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &tcp_nodelay_on, sizeof (tcp_nodelay_on)) == -1)
|
||||
{
|
||||
_dbus_warn ("Failed to set TCP_NODELAY socket option \"%s:%s\": %s",
|
||||
host ? host : "*", port, _dbus_strerror (errno));
|
||||
}
|
||||
|
||||
if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) < 0)
|
||||
{
|
||||
saved_errno = errno;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue