[Spice-devel] [PATCH spice] server: Don't complain if setsockopt NODELAY fails on unix sockets

Hans de Goede hdegoede at redhat.com
Wed Jan 18 01:50:08 PST 2012


With Daniel P. Berrange's patches to allow use of pre-supplied fd's
as channels, we can no longer be sure that our connections are TCP
sockets, so it makes no sense to complain if a TCP/IP specific
setsockopt fails with an errno of ENOTSUP.

Note that this extends Daniel's commit 492ddb5d1d595e2d12208f4602b18e4432f4e6b4
which already added the same check to server/inputs_channel.c

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 server/red_tunnel_worker.c |    4 +++-
 server/red_worker.c        |    4 +++-
 server/reds.c              |    4 +++-
 server/snd_worker.c        |    8 ++++++--
 server/spicevmc.c          |    6 ++++--
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 250e8b3..8dae76e 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -3365,7 +3365,9 @@ static int tunnel_channel_config_socket(RedChannelClient *rcc)
 
     if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY, &delay_val,
                    sizeof(delay_val)) == -1) {
-        red_printf("setsockopt failed, %s", strerror(errno));
+        if (errno != ENOTSUP) {
+            red_printf("setsockopt failed, %s", strerror(errno));
+        }
     }
 
     return TRUE;
diff --git a/server/red_worker.c b/server/red_worker.c
index d096ee4..a1a2eab 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9500,7 +9500,9 @@ static int common_channel_config_socket(RedChannelClient *rcc)
     // TODO - this should be dynamic, not one time at channel creation
     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) {
-        red_printf("setsockopt failed, %s", strerror(errno));
+        if (errno != ENOTSUP) {
+            red_printf("setsockopt failed, %s", strerror(errno));
+        }
     }
     return TRUE;
 }
diff --git a/server/reds.c b/server/reds.c
index b97a061..2492a89 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2706,7 +2706,9 @@ static RedLinkInfo *reds_init_client_connection(int socket)
     }
 
     if (setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &delay_val, sizeof(delay_val)) == -1) {
-        red_printf("setsockopt failed, %s", strerror(errno));
+        if (errno != ENOTSUP) {
+            red_printf("setsockopt failed, %s", strerror(errno));
+        }
     }
 
     link = spice_new0(RedLinkInfo, 1);
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 5d58077..b96d202 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -919,12 +919,16 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
 
     tos = IPTOS_LOWDELAY;
     if (setsockopt(stream->socket, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) == -1) {
-        red_printf("setsockopt failed, %s", strerror(errno));
+        if (errno != ENOTSUP) {
+            red_printf("setsockopt failed, %s", strerror(errno));
+        }
     }
 
     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) {
-        red_printf("setsockopt failed, %s", strerror(errno));
+        if (errno != ENOTSUP) {
+            red_printf("setsockopt failed, %s", strerror(errno));
+        }
     }
 
     if (fcntl(stream->socket, F_SETFL, flags | O_NONBLOCK) == -1) {
diff --git a/server/spicevmc.c b/server/spicevmc.c
index c2e249c..5cdc513 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -92,8 +92,10 @@ static int spicevmc_red_channel_client_config_socket(RedChannelClient *rcc)
     if (rcc->channel->type == SPICE_CHANNEL_USBREDIR) {
         if (setsockopt(stream->socket, IPPROTO_TCP, TCP_NODELAY,
                 &delay_val, sizeof(delay_val)) != 0) {
-            red_printf("setsockopt failed, %s", strerror(errno));
-            return FALSE;
+            if (errno != ENOTSUP) {
+                red_printf("setsockopt failed, %s", strerror(errno));
+                return FALSE;
+            }
         }
     }
 
-- 
1.7.7.4



More information about the Spice-devel mailing list