[Spice-devel] [PATCH spice-server 19/33] windows: Disable code not working on Windows

Marc-André Lureau marcandre.lureau at gmail.com
Sat Dec 22 10:17:19 UTC 2018


On Fri, Dec 21, 2018 at 4:04 PM Frediano Ziglio <fziglio at redhat.com> wrote:
>
> - 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>

Looks good,
Reviewed-by: Marc-André Lureau <marcandre.lureau 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                   |  4 ++++
>  server/sound.c                  |  2 ++
>  server/stat-file.c              |  2 ++
>  server/tests/basic-event-loop.c |  2 ++
>  server/tests/replay.c           |  2 ++
>  tools/Makefile.am               |  2 ++
>  10 files changed, 34 insertions(+), 1 deletion(-)
>
> diff --git a/server/red-channel-client.c b/server/red-channel-client.c
> index 07f1988d..ac67efbb 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -627,6 +627,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)) {
> @@ -640,6 +641,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 33086d99..a6da8385 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(socket_t socket, int enabled)
>      SPICE_VERIFY(sizeof(enabled) == sizeof(int));
>      return socket_setopt(socket, IPPROTO_TCP, TCP_CORK, &enabled, sizeof(enabled));
>  }
> +#else
> +static inline int socket_set_cork(socket_t 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 52082f68..5d8cbb05 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 f016943a..10cabf00 100644
> --- a/server/red-worker.c
> +++ b/server/red-worker.c
> @@ -1359,22 +1359,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 2897aecb..b3294357 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -2529,6 +2529,7 @@ static socket_t reds_init_socket(const char *addr, int portnr, int family)
>      socket_t slisten;
>
>      if (family == AF_UNIX) {
> +#ifndef _WIN32
>          int len;
>          struct sockaddr_un local = { 0, };
>
> @@ -2549,6 +2550,9 @@ static socket_t reds_init_socket(const char *addr, int portnr, int family)
>          }
>
>          goto listen;
> +#else
> +        return SOCKET_INVALID;
> +#endif
>      }
>
>      memset(&ai,0, sizeof(ai));
> diff --git a/server/sound.c b/server/sound.c
> index 00b473a8..482f4bc6 100644
> --- a/server/sound.c
> +++ b/server/sound.c
> @@ -790,6 +790,7 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
>      }
>  #endif
>
> +#ifdef IPTOS_LOWDELAY
>      int tos = IPTOS_LOWDELAY;
>      if (socket_setopt(stream->socket, IPPROTO_IP, IP_TOS, (void*)&tos, sizeof(tos)) == -1) {
>          if (errno != ENOTSUP) {
> @@ -798,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 b2c199f3..e5a89e22 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 76b0580e..e021cfb3 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 b689044a..cbb1c195 100644
> --- a/server/tests/replay.c
> +++ b/server/tests/replay.c
> @@ -401,10 +401,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 cfb0a213..702fcdd1 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 \
> --
> 2.17.2
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel



--
Marc-André Lureau


More information about the Spice-devel mailing list