Commit a0ac4c40 authored by Ralf Habacker's avatar Ralf Habacker

Windows _dbus_listen_tcp_socket: Set socket options SO_REUSEADDR and TCP_NODELAY

Reviewed-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
parent 98a5011b
......@@ -1739,7 +1739,9 @@ _dbus_listen_tcp_socket (const char *host,
tmp = ai;
while (tmp)
{
const int reuseaddr = 1, tcp_nodelay_on = 1;
DBusSocket fd = DBUS_SOCKET_INIT, *newlisten_fd;
if ((fd.sock = socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
saved_errno = _dbus_get_low_level_socket_errno ();
......@@ -1751,6 +1753,22 @@ _dbus_listen_tcp_socket (const char *host,
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
if (setsockopt (fd.sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&reuseaddr, sizeof(reuseaddr)) == SOCKET_ERROR)
{
saved_errno = _dbus_get_low_level_socket_errno ();
_dbus_warn ("Failed to set socket option \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror (saved_errno));
}
/* Nagle's algorithm imposes a huge delay on the initial messages
going over TCP. */
if (setsockopt (fd.sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&tcp_nodelay_on, sizeof (tcp_nodelay_on)) == SOCKET_ERROR)
{
saved_errno = _dbus_get_low_level_socket_errno ();
_dbus_warn ("Failed to set TCP_NODELAY socket option \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror (saved_errno));
}
if (bind (fd.sock, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
{
saved_errno = _dbus_get_low_level_socket_errno ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment