[Spice-commits] 6 commits - configure.ac server/Makefile.am server/common-graphics-channel.c server/net-utils.c server/net-utils.h server/red-channel-client.c server/reds-stream.c server/reds-stream.h server/reds.c server/sound.c spice-common

Christophe Fergau teuf at kemper.freedesktop.org
Fri Mar 31 10:23:17 UTC 2017


 configure.ac                     |    5 +
 server/Makefile.am               |    2 
 server/common-graphics-channel.c |   13 ---
 server/net-utils.c               |  138 +++++++++++++++++++++++++++++++++++++++
 server/net-utils.h               |   28 +++++++
 server/red-channel-client.c      |   24 +-----
 server/reds-stream.c             |   18 +++++
 server/reds-stream.h             |    2 
 server/reds.c                    |   46 +------------
 server/sound.c                   |    8 --
 spice-common                     |    2 
 11 files changed, 207 insertions(+), 79 deletions(-)

New commits:
commit 27a9450d075d9cc1537dd63b70a4a32cceee384f
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 16 16:02:11 2017 +0100

    build-sys: Add configure check for TCP_KEEPIDLE
    
    This is only available in newer FreeBSD releases (9.1 and later), and
    will cause build errors or older versions
    
    This fixes https://bugs.freedesktop.org/show_bug.cgi?id=99213
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/configure.ac b/configure.ac
index c2a6c2d8..66b9a17c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,11 @@ AC_C_BIGENDIAN
 PKG_PROG_PKG_CONFIG
 
 AC_CHECK_HEADERS([sys/time.h execinfo.h linux/sockios.h])
+AC_CHECK_DECL([TCP_KEEPIDLE], [have_tcp_keepidle="yes"],,
+              [#include <netinet/tcp.h>])
+AS_IF([test "x$have_tcp_keepidle" = "xyes"],
+      [AC_DEFINE([HAVE_TCP_KEEPIDLE],1,[Define to 1 if <netinet/tcp.h> has a TCP_KEEPIDLE definition])],
+)
 AC_FUNC_ALLOCA
 
 SPICE_LT_VERSION=m4_format("%d:%d:%d", SPICE_CURRENT, SPICE_REVISION, SPICE_AGE)
diff --git a/server/net-utils.c b/server/net-utils.c
index 209c2987..06fb8b13 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -53,12 +53,14 @@ bool red_socket_set_keepalive(int fd, bool enable, int timeout)
         return true;
     }
 
+#ifdef HAVE_TCP_KEEPIDLE
     if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
         if (errno != ENOTSUP) {
             spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
             return false;
         }
     }
+#endif
 
     return true;
 }
commit eb9f69ed9a0b8f4c80c8069e72666b57210b8f05
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 16 16:02:10 2017 +0100

    reds-stream: Introduce reds_stream_get_no_delay() helper
    
    This new function removes one place outside of RedsStream which needs to
    access RedsStream::socket
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/net-utils.c b/server/net-utils.c
index ae7fa91a..209c2987 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -114,3 +114,23 @@ bool red_socket_set_non_blocking(int fd, bool non_blocking)
 
     return true;
 }
+
+/**
+ * red_socket_get_no_delay:
+ * @fd: a socket file descriptor
+ *
+ * Returns: The current value of TCP_NODELAY for @fd, -1 if an error occurred
+ */
+int red_socket_get_no_delay(int fd)
+{
+    int delay_val;
+    socklen_t opt_size = sizeof(delay_val);
+
+    if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &delay_val,
+                   &opt_size) == -1) {
+            spice_warning("getsockopt failed, %s", strerror(errno));
+            return -1;
+    }
+
+    return delay_val;
+}
diff --git a/server/net-utils.h b/server/net-utils.h
index 7fe5d342..f95d689a 100644
--- a/server/net-utils.h
+++ b/server/net-utils.h
@@ -22,6 +22,7 @@
 
 bool red_socket_set_keepalive(int fd, bool enable, int timeout);
 bool red_socket_set_no_delay(int fd, bool no_delay);
+int red_socket_get_no_delay(int fd);
 bool red_socket_set_non_blocking(int fd, bool non_blocking);
 
 #endif /* RED_NET_UTILS_H_ */
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index c9879f52..ef0e8926 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -556,7 +556,6 @@ static void red_channel_client_send_ping(RedChannelClient *rcc)
 
     if (!rcc->priv->latency_monitor.warmup_was_sent) { // latency test start
         int delay_val;
-        socklen_t opt_size = sizeof(delay_val);
 
         rcc->priv->latency_monitor.warmup_was_sent = TRUE;
         /*
@@ -565,10 +564,8 @@ static void red_channel_client_send_ping(RedChannelClient *rcc)
          * roundtrip measurement is less accurate (bigger).
          */
         rcc->priv->latency_monitor.tcp_nodelay = 1;
-        if (getsockopt(rcc->priv->stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
-                       &opt_size) == -1) {
-            spice_warning("getsockopt failed, %s", strerror(errno));
-        }  else {
+        delay_val = reds_stream_get_no_delay(rcc->priv->stream);
+        if (delay_val != -1) {
             rcc->priv->latency_monitor.tcp_nodelay = delay_val;
             if (!delay_val) {
                 reds_stream_set_no_delay(rcc->priv->stream, TRUE);
diff --git a/server/reds-stream.c b/server/reds-stream.c
index 7927b559..2ea54756 100644
--- a/server/reds-stream.c
+++ b/server/reds-stream.c
@@ -272,6 +272,11 @@ bool reds_stream_set_no_delay(RedsStream *stream, bool no_delay)
     return red_socket_set_no_delay(stream->socket, no_delay);
 }
 
+int reds_stream_get_no_delay(RedsStream *stream)
+{
+    return red_socket_get_no_delay(stream->socket);
+}
+
 int reds_stream_send_msgfd(RedsStream *stream, int fd)
 {
     struct msghdr msgh = { 0, };
diff --git a/server/reds-stream.h b/server/reds-stream.h
index d92d3ec7..2dc39c23 100644
--- a/server/reds-stream.h
+++ b/server/reds-stream.h
@@ -73,6 +73,7 @@ int reds_stream_enable_ssl(RedsStream *stream, SSL_CTX *ctx);
 int reds_stream_get_family(const RedsStream *stream);
 bool reds_stream_is_plain_unix(const RedsStream *stream);
 bool reds_stream_set_no_delay(RedsStream *stream, bool no_delay);
+int reds_stream_get_no_delay(RedsStream *stream);
 int reds_stream_send_msgfd(RedsStream *stream, int fd);
 
 typedef enum {
commit 5ca3d6ca5023f3d0d6d128482d0cf04699813518
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 16 16:02:09 2017 +0100

    net: Introduce red_socket_set_keepalive() helper
    
    This allows to move some low-level code out of reds.c
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/net-utils.c b/server/net-utils.c
index b017daa9..ae7fa91a 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -32,6 +32,38 @@
 #include "net-utils.h"
 
 /**
+ * red_socket_set_keepalive:
+ * @fd: a socket file descriptor
+ * @keepalive: whether to enable keepalives on @fd
+ *
+ * Returns: #true if the operation succeeded, #false otherwise.
+ */
+bool red_socket_set_keepalive(int fd, bool enable, int timeout)
+{
+    int keepalive = !!enable;
+
+    if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) == -1) {
+        if (errno != ENOTSUP) {
+            spice_printerr("setsockopt for keepalive failed, %s", strerror(errno));
+            return false;
+        }
+    }
+
+    if (!enable) {
+        return true;
+    }
+
+    if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &timeout, sizeof(timeout)) == -1) {
+        if (errno != ENOTSUP) {
+            spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
+            return false;
+        }
+    }
+
+    return true;
+}
+
+/**
  * red_socket_set_no_delay:
  * @fd: a socket file descriptor
  * @no_delay: whether to enable TCP_NODELAY on @fd
diff --git a/server/net-utils.h b/server/net-utils.h
index 8da6e429..7fe5d342 100644
--- a/server/net-utils.h
+++ b/server/net-utils.h
@@ -20,6 +20,7 @@
 
 #include <stdbool.h>
 
+bool red_socket_set_keepalive(int fd, bool enable, int timeout);
 bool red_socket_set_no_delay(int fd, bool no_delay);
 bool red_socket_set_non_blocking(int fd, bool non_blocking);
 
diff --git a/server/reds.c b/server/reds.c
index ebe26522..49b0ef00 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2378,29 +2378,6 @@ static void reds_handle_ssl_accept(int fd, int event, void *data)
 
 #define KEEPALIVE_TIMEOUT (10*60)
 
-static bool reds_init_keepalive(int socket)
-{
-    int keepalive = 1;
-    int keepalive_timeout = KEEPALIVE_TIMEOUT;
-
-    if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &keepalive, sizeof(keepalive)) == -1) {
-        if (errno != ENOTSUP) {
-            spice_printerr("setsockopt for keepalive failed, %s", strerror(errno));
-            return false;
-        }
-    }
-
-    if (setsockopt(socket, SOL_TCP, TCP_KEEPIDLE,
-                   &keepalive_timeout, sizeof(keepalive_timeout)) == -1) {
-        if (errno != ENOTSUP) {
-            spice_printerr("setsockopt for keepalive timeout failed, %s", strerror(errno));
-            return false;
-        }
-    }
-
-    return true;
-}
-
 static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
 {
     RedLinkInfo *link;
@@ -2413,7 +2390,7 @@ static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
        goto error;
     }
 
-    reds_init_keepalive(socket);
+    red_socket_set_keepalive(socket, TRUE, KEEPALIVE_TIMEOUT);
 
     link = spice_new0(RedLinkInfo, 1);
     link->reds = reds;
commit b85ca4b8a9e103734e2018a1def49f6430daa03c
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 16 16:02:08 2017 +0100

    net: Introduce red_socket_set_non_blocking() helper
    
    This allows to move some low-level code out of reds.c
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/net-utils.c b/server/net-utils.c
index 10f447b5..b017daa9 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -52,3 +52,33 @@ bool red_socket_set_no_delay(int fd, bool no_delay)
 
     return true;
 }
+
+/**
+ * red_socket_set_non_blocking:
+ * @fd: a socket file descriptor
+ * @non_blocking: whether to enable O_NONBLOCK on @fd
+ *
+ * Returns: #true if the operation succeeded, #false otherwise.
+ */
+bool red_socket_set_non_blocking(int fd, bool non_blocking)
+{
+    int flags;
+
+    if ((flags = fcntl(fd, F_GETFL)) == -1) {
+        spice_warning("fnctl(F_GETFL) failed, %s", strerror(errno));
+        return false;
+    }
+
+    if (non_blocking) {
+        flags |= O_NONBLOCK;
+    } else {
+        flags &= ~O_NONBLOCK;
+    }
+
+    if (fcntl(fd, F_SETFL, flags) == -1) {
+        spice_warning("fnctl(F_SETFL) failed, %s", strerror(errno));
+        return false;
+    }
+
+    return true;
+}
diff --git a/server/net-utils.h b/server/net-utils.h
index 1c066416..8da6e429 100644
--- a/server/net-utils.h
+++ b/server/net-utils.h
@@ -21,5 +21,6 @@
 #include <stdbool.h>
 
 bool red_socket_set_no_delay(int fd, bool no_delay);
+bool red_socket_set_non_blocking(int fd, bool non_blocking);
 
 #endif /* RED_NET_UTILS_H_ */
diff --git a/server/reds.c b/server/reds.c
index 643f324c..ebe26522 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -31,8 +31,6 @@
 #include <limits.h>
 #include <pthread.h>
 #include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
 #include <ctype.h>
 
 #include <openssl/err.h>
@@ -2406,16 +2404,9 @@ static bool reds_init_keepalive(int socket)
 static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
 {
     RedLinkInfo *link;
-    int flags;
 
-    if ((flags = fcntl(socket, F_GETFL)) == -1) {
-        spice_warning("accept failed, %s", strerror(errno));
-        goto error;
-    }
-
-    if (fcntl(socket, F_SETFL, flags | O_NONBLOCK) == -1) {
-        spice_warning("accept failed, %s", strerror(errno));
-        goto error;
+    if (!red_socket_set_non_blocking(socket, TRUE)) {
+       goto error;
     }
 
     if (!red_socket_set_no_delay(socket, TRUE)) {
commit ecf05ed6be919205f6f750c921a3634051cccf33
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 16 16:02:07 2017 +0100

    reds-stream: Introduce reds_stream_set_no_delay() helper
    
    The code to enable/disable on a TCP socket is duplicated in multiple
    places in the code base, this commit replaces this duplicated code with
    a helper in RedsStream.
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/server/Makefile.am b/server/Makefile.am
index 74a1302c..ef8d31fc 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -125,6 +125,8 @@ libserver_la_SOURCES =				\
 	memslot.h				\
 	migration-protocol.h			\
 	mjpeg-encoder.c				\
+	net-utils.c				\
+	net-utils.h				\
 	pixmap-cache.c				\
 	pixmap-cache.h				\
 	red-channel.c				\
diff --git a/server/common-graphics-channel.c b/server/common-graphics-channel.c
index 91374fc5..e8c18a52 100644
--- a/server/common-graphics-channel.c
+++ b/server/common-graphics-channel.c
@@ -19,9 +19,6 @@
 #endif
 
 #include <fcntl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
 
 #include "common-graphics-channel.h"
 #include "dcc.h"
@@ -125,24 +122,18 @@ bool common_channel_client_config_socket(RedChannelClient *rcc)
     RedClient *client = red_channel_client_get_client(rcc);
     MainChannelClient *mcc = red_client_get_main(client);
     RedsStream *stream = red_channel_client_get_stream(rcc);
-    int delay_val;
     gboolean is_low_bandwidth;
 
     // TODO - this should be dynamic, not one time at channel creation
     is_low_bandwidth = main_channel_client_is_low_bandwidth(mcc);
-    delay_val = is_low_bandwidth ? 0 : 1;
     /* FIXME: Using Nagle's Algorithm can lead to apparent delays, depending
      * on the delayed ack timeout on the other side.
      * Instead of using Nagle's, we need to implement message buffering on
      * the application level.
      * see: http://www.stuartcheshire.org/papers/NagleDelayedAck/
      */
-    if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
-                   sizeof(delay_val)) == -1) {
-        if (errno != ENOTSUP) {
-            spice_warning("setsockopt failed, %s", strerror(errno));
-        }
-    }
+    reds_stream_set_no_delay(stream, !is_low_bandwidth);
+
     // TODO: move wide/narrow ack setting to red_channel.
     red_channel_client_ack_set_client_window(rcc,
         is_low_bandwidth ?
diff --git a/server/net-utils.c b/server/net-utils.c
new file mode 100644
index 00000000..10f447b5
--- /dev/null
+++ b/server/net-utils.c
@@ -0,0 +1,54 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+   Copyright (C) 2009, 2017 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <string.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <sys/socket.h>
+
+#include <common/log.h>
+
+#include "net-utils.h"
+
+/**
+ * red_socket_set_no_delay:
+ * @fd: a socket file descriptor
+ * @no_delay: whether to enable TCP_NODELAY on @fd
+ *
+ * Returns: #true if the operation succeeded, #false otherwise.
+ */
+bool red_socket_set_no_delay(int fd, bool no_delay)
+{
+    int optval = no_delay;
+
+    if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
+                   &optval, sizeof(optval)) != 0) {
+        if (errno != ENOTSUP && errno != ENOPROTOOPT) {
+            spice_warning("setsockopt failed, %s", strerror(errno));
+            return false;
+        }
+    }
+
+    return true;
+}
diff --git a/server/net-utils.h b/server/net-utils.h
new file mode 100644
index 00000000..1c066416
--- /dev/null
+++ b/server/net-utils.h
@@ -0,0 +1,25 @@
+/*
+   Copyright (C) 2009-2017 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef RED_NET_UTILS_H_
+#define RED_NET_UTILS_H_
+
+#include <stdbool.h>
+
+bool red_socket_set_no_delay(int fd, bool no_delay);
+
+#endif /* RED_NET_UTILS_H_ */
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 447f29bb..c9879f52 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -571,13 +571,7 @@ static void red_channel_client_send_ping(RedChannelClient *rcc)
         }  else {
             rcc->priv->latency_monitor.tcp_nodelay = delay_val;
             if (!delay_val) {
-                delay_val = 1;
-                if (setsockopt(rcc->priv->stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
-                               sizeof(delay_val)) == -1) {
-                   if (errno != ENOTSUP) {
-                        spice_warning("setsockopt failed, %s", strerror(errno));
-                    }
-                }
+                reds_stream_set_no_delay(rcc->priv->stream, TRUE);
             }
         }
     }
@@ -1366,14 +1360,7 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing *
 
     /* set TCP_NODELAY=0, in case we reverted it for the test*/
     if (!rcc->priv->latency_monitor.tcp_nodelay) {
-        int delay_val = 0;
-
-        if (setsockopt(rcc->priv->stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
-                       sizeof(delay_val)) == -1) {
-            if (errno != ENOTSUP) {
-                spice_warning("setsockopt failed, %s", strerror(errno));
-            }
-        }
+        reds_stream_set_no_delay(rcc->priv->stream, FALSE);
     }
 
     /*
diff --git a/server/reds-stream.c b/server/reds-stream.c
index 77f9424d..7927b559 100644
--- a/server/reds-stream.c
+++ b/server/reds-stream.c
@@ -32,6 +32,7 @@
 #include <common/log.h>
 
 #include "main-dispatcher.h"
+#include "net-utils.h"
 #include "red-common.h"
 #include "reds-stream.h"
 #include "reds.h"
@@ -259,6 +260,18 @@ bool reds_stream_is_plain_unix(const RedsStream *s)
 
 }
 
+/**
+ * reds_stream_set_no_delay:
+ * @stream: a #RedsStream
+ * @no_delay: whether to enable TCP_NODELAY on @@stream
+ *
+ * Returns: #true if the operation succeeded, #false otherwise.
+ */
+bool reds_stream_set_no_delay(RedsStream *stream, bool no_delay)
+{
+    return red_socket_set_no_delay(stream->socket, no_delay);
+}
+
 int reds_stream_send_msgfd(RedsStream *stream, int fd)
 {
     struct msghdr msgh = { 0, };
diff --git a/server/reds-stream.h b/server/reds-stream.h
index ac5c65bb..d92d3ec7 100644
--- a/server/reds-stream.h
+++ b/server/reds-stream.h
@@ -72,6 +72,7 @@ RedsStreamSslStatus reds_stream_ssl_accept(RedsStream *stream);
 int reds_stream_enable_ssl(RedsStream *stream, SSL_CTX *ctx);
 int reds_stream_get_family(const RedsStream *stream);
 bool reds_stream_is_plain_unix(const RedsStream *stream);
+bool reds_stream_set_no_delay(RedsStream *stream, bool no_delay);
 int reds_stream_send_msgfd(RedsStream *stream, int fd);
 
 typedef enum {
diff --git a/server/reds.c b/server/reds.c
index 839ffe7d..643f324c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -75,6 +75,7 @@
 #include "main-channel-client.h"
 #include "red-client.h"
 #include "glib-compat.h"
+#include "net-utils.h"
 
 #define REDS_MAX_STAT_NODES 100
 
@@ -2405,7 +2406,6 @@ static bool reds_init_keepalive(int socket)
 static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
 {
     RedLinkInfo *link;
-    int delay_val = 1;
     int flags;
 
     if ((flags = fcntl(socket, F_GETFL)) == -1) {
@@ -2418,10 +2418,8 @@ static RedLinkInfo *reds_init_client_connection(RedsState *reds, int socket)
         goto error;
     }
 
-    if (setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
-        if (errno != ENOTSUP) {
-            spice_warning("setsockopt failed, %s", strerror(errno));
-        }
+    if (!red_socket_set_no_delay(socket, TRUE)) {
+       goto error;
     }
 
     reds_init_keepalive(socket);
diff --git a/server/sound.c b/server/sound.c
index 9a80bb7c..75bd0e7d 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -734,7 +734,6 @@ static void record_channel_send_item(RedChannelClient *rcc, G_GNUC_UNUSED RedPip
 
 static bool snd_channel_client_config_socket(RedChannelClient *rcc)
 {
-    int delay_val;
 #ifdef SO_PRIORITY
     int priority;
 #endif
@@ -760,12 +759,7 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
         }
     }
 
-    delay_val = main_channel_client_is_low_bandwidth(mcc) ? 0 : 1;
-    if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
-        if (errno != ENOTSUP) {
-            spice_printerr("setsockopt failed, %s", strerror(errno));
-        }
-    }
+    reds_stream_set_no_delay(stream, !main_channel_client_is_low_bandwidth(mcc));
 
     return TRUE;
 }
commit fa44ecb5b6a0f8432762dc06322a7ec1bfa93185
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Mar 16 16:02:06 2017 +0100

    common: Update spice-common submodule
    
    This brings in these changes:
    
    Christophe Fergeau (1):
          log: Add missing stdio.h include
    
    Frediano Ziglio (2):
          protocol: Add support for VP9 video codec
          region: Avoid possible memory corruption
    
    Jonathon Jongsma (1):
          Document REGION_TEST_* bitmasks
    
    Marc-André Lureau (1):
          build-sys: don't dist spice-protocol.html
    
    Sebastian Andrzej Siewior (1):
          ssl: Use ASN1_STRING_get0_data instead of ASN1_STRING_data
    
    Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
    Acked-by: Frediano Ziglio <fziglio at redhat.com>

diff --git a/spice-common b/spice-common
index 6439bec0..0996c33d 160000
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit 6439bec0deed0fcf251d4d77514b7c4a87384097
+Subproject commit 0996c33d6d13d4d89ab99ad7f447fdf984982c0c


More information about the Spice-commits mailing list