[Spice-devel] [PATCH spice-server v5 13/18] windows: Disable code not working on Windows

Frediano Ziglio fziglio at redhat.com
Fri Mar 29 09:00:09 UTC 2019


- global signals;
- CLOEXEC flag;
- mmap and statistics;
- IPTOS_LOWDELAY flag;
- Unix sockets;
- sharing file descriptors through Unix sockets;
- TCP_CORK flag.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/red-channel-client.c     |  2 ++
 server/red-stream.c             | 11 ++++++++++-
 server/red-stream.h             |  2 ++
 server/red-worker.c             |  6 ++++++
 server/reds.c                   |  7 ++++++-
 server/sound.c                  |  5 +++--
 server/stat-file.c              |  2 ++
 server/tests/basic-event-loop.c |  2 ++
 server/tests/replay.c           |  2 ++
 tools/Makefile.am               |  2 ++
 tools/meson.build               | 10 ++++++----
 11 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 9aa767927..e6daddba5 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -624,6 +624,7 @@ static void red_channel_client_restore_main_sender(RedChannelClient *rcc)
 
 static void red_channel_client_msg_sent(RedChannelClient *rcc)
 {
+#ifndef _WIN32
     int fd;
 
     if (spice_marshaller_get_fd(rcc->priv->send_data.marshaller, &fd)) {
@@ -637,6 +638,7 @@ static void red_channel_client_msg_sent(RedChannelClient *rcc)
         if (fd != -1)
             close(fd);
     }
+#endif
 
     red_channel_client_clear_sent_item(rcc);
 
diff --git a/server/red-stream.c b/server/red-stream.c
index ab3d87c7c..e8e88fb39 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -41,7 +41,7 @@
 #include "reds.h"
 
 // compatibility for *BSD systems
-#ifndef TCP_CORK
+#if !defined(TCP_CORK) && !defined(_WIN32)
 #define TCP_CORK TCP_NOPUSH
 #endif
 
@@ -102,6 +102,7 @@ struct RedStreamPrivate {
     SpiceCoreInterfaceInternal *core;
 };
 
+#ifndef _WIN32
 /**
  * Set TCP_CORK on socket
  */
@@ -111,6 +112,12 @@ static int socket_set_cork(int socket, int enabled)
     SPICE_VERIFY(sizeof(enabled) == sizeof(int));
     return setsockopt(socket, IPPROTO_TCP, TCP_CORK, &enabled, sizeof(enabled));
 }
+#else
+static inline int socket_set_cork(int socket, int enabled)
+{
+    return -1;
+}
+#endif
 
 static ssize_t stream_write_cb(RedStream *s, const void *buf, size_t size)
 {
@@ -318,6 +325,7 @@ int red_stream_get_no_delay(RedStream *stream)
     return red_socket_get_no_delay(stream->socket);
 }
 
+#ifndef _WIN32
 int red_stream_send_msgfd(RedStream *stream, int fd)
 {
     struct msghdr msgh = { 0, };
@@ -360,6 +368,7 @@ int red_stream_send_msgfd(RedStream *stream, int fd)
 
     return r;
 }
+#endif
 
 ssize_t red_stream_writev(RedStream *s, const struct iovec *iov, int iovcnt)
 {
diff --git a/server/red-stream.h b/server/red-stream.h
index 9a7cc617e..ca6dc71a9 100644
--- a/server/red-stream.h
+++ b/server/red-stream.h
@@ -67,7 +67,9 @@ int red_stream_get_family(const RedStream *stream);
 bool red_stream_is_plain_unix(const RedStream *stream);
 bool red_stream_set_no_delay(RedStream *stream, bool no_delay);
 int red_stream_get_no_delay(RedStream *stream);
+#ifndef _WIN32
 int red_stream_send_msgfd(RedStream *stream, int fd);
+#endif
 
 /**
  * Set auto flush flag.
diff --git a/server/red-worker.c b/server/red-worker.c
index bc63fc34f..acde680ee 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1145,22 +1145,28 @@ static void *red_worker_main(void *arg)
 
 bool red_worker_run(RedWorker *worker)
 {
+#ifndef _WIN32
     sigset_t thread_sig_mask;
     sigset_t curr_sig_mask;
+#endif
     int r;
 
     spice_return_val_if_fail(worker, FALSE);
     spice_return_val_if_fail(!worker->thread, FALSE);
 
+#ifndef _WIN32
     sigfillset(&thread_sig_mask);
     sigdelset(&thread_sig_mask, SIGILL);
     sigdelset(&thread_sig_mask, SIGFPE);
     sigdelset(&thread_sig_mask, SIGSEGV);
     pthread_sigmask(SIG_SETMASK, &thread_sig_mask, &curr_sig_mask);
+#endif
     if ((r = pthread_create(&worker->thread, NULL, red_worker_main, worker))) {
         spice_error("create thread failed %d", r);
     }
+#ifndef _WIN32
     pthread_sigmask(SIG_SETMASK, &curr_sig_mask, NULL);
+#endif
     pthread_setname_np(worker->thread, "SPICE Worker");
 
     return r == 0;
diff --git a/server/reds.c b/server/reds.c
index 71a03bd0b..08b5875a4 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2646,9 +2646,11 @@ static int reds_init_socket(const char *addr, int portnr, int family)
     static const int on=1, off=0;
     struct addrinfo ai,*res,*e;
     char port[33];
-    int slisten, rc, len;
+    int slisten, rc;
 
     if (family == AF_UNIX) {
+#ifndef _WIN32
+        int len;
         struct sockaddr_un local = { 0, };
 
         if ((slisten = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
@@ -2667,6 +2669,9 @@ static int reds_init_socket(const char *addr, int portnr, int family)
         }
 
         goto listen;
+#else
+        return -1;
+#endif
     }
 
     memset(&ai,0, sizeof(ai));
diff --git a/server/sound.c b/server/sound.c
index 167f68c57..21c1937b7 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -775,7 +775,6 @@ static void record_channel_send_item(RedChannelClient *rcc, G_GNUC_UNUSED RedPip
 
 static bool snd_channel_client_config_socket(RedChannelClient *rcc)
 {
-    int tos;
     RedStream *stream = red_channel_client_get_stream(rcc);
     RedClient *red_client = red_channel_client_get_client(rcc);
     MainChannelClient *mcc = red_client_get_main(red_client);
@@ -791,7 +790,8 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
     }
 #endif
 
-    tos = IPTOS_LOWDELAY;
+#ifdef IPTOS_LOWDELAY
+    int tos = IPTOS_LOWDELAY;
     if (setsockopt(stream->socket, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) == -1) {
         if (errno != ENOTSUP) {
             red_channel_warning(red_channel_client_get_channel(rcc),
@@ -799,6 +799,7 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
                                 strerror(errno));
         }
     }
+#endif
 
     red_stream_set_no_delay(stream, !main_channel_client_is_low_bandwidth(mcc));
 
diff --git a/server/stat-file.c b/server/stat-file.c
index b2c199f32..e5a89e228 100644
--- a/server/stat-file.c
+++ b/server/stat-file.c
@@ -19,6 +19,7 @@
 #include <config.h>
 #endif
 
+#ifndef _WIN32
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -236,3 +237,4 @@ void stat_file_remove_counter(RedStatFile *stat_file, uint64_t *counter)
 {
     stat_file_remove(stat_file, (SpiceStatNode *)(counter - SPICE_OFFSETOF(SpiceStatNode, value)));
 }
+#endif
diff --git a/server/tests/basic-event-loop.c b/server/tests/basic-event-loop.c
index 607a5a5ee..e331e8522 100644
--- a/server/tests/basic-event-loop.c
+++ b/server/tests/basic-event-loop.c
@@ -68,12 +68,14 @@ void basic_event_loop_quit(void)
 
 static void ignore_sigpipe(void)
 {
+#ifndef _WIN32
     struct sigaction act;
 
     memset(&act, 0, sizeof(act));
     sigfillset(&act.sa_mask);
     act.sa_handler = SIG_IGN;
     sigaction(SIGPIPE, &act, NULL);
+#endif
 }
 
 static SpiceTimer* base_timer_add(SpiceTimerFunc func, void *opaque)
diff --git a/server/tests/replay.c b/server/tests/replay.c
index f7d26fec0..6367ce21a 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -411,10 +411,12 @@ int main(int argc, char **argv)
     }
     g_strfreev(file);
     file = NULL;
+#ifndef _WIN32
     if (fcntl(fileno(fd), FD_CLOEXEC) < 0) {
         perror("fcntl failed");
         exit(1);
     }
+#endif
     fseek(fd, 0L, SEEK_END);
     total_size = ftell(fd);
     fseek(fd, 0L, SEEK_SET);
diff --git a/tools/Makefile.am b/tools/Makefile.am
index cfb0a2137..702fcdd1e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -10,6 +10,7 @@ AM_LDFLAGS = \
 	$(LIBRT) \
 	$(NULL)
 
+if !OS_WIN32
 noinst_PROGRAMS = \
 	reds_stat \
 	$(NULL)
@@ -17,6 +18,7 @@ noinst_PROGRAMS = \
 reds_stat_SOURCES = \
 	reds_stat.c \
 	$(NULL)
+endif
 
 EXTRA_DIST = \
 	meson.build \
diff --git a/tools/meson.build b/tools/meson.build
index 1d78340bb..8ec2cc918 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,4 +1,6 @@
-executable('reds_stat', 'reds_stat.c',
-           install : false,
-           include_directories : spice_server_include,
-           dependencies : spice_server_deps)
+if host_machine.system() != 'windows'
+  executable('reds_stat', 'reds_stat.c',
+             install : false,
+             include_directories : spice_server_include,
+             dependencies : spice_server_deps)
+endif
-- 
2.20.1



More information about the Spice-devel mailing list