- 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@xxxxxxxxxx> --- 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 ce4f4194..4978f356 100644 --- a/server/red-channel-client.c +++ b/server/red-channel-client.c @@ -622,6 +622,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)) { @@ -635,6 +636,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 af7036e5..4706acae 100644 --- a/server/red-stream.c +++ b/server/red-stream.c @@ -39,7 +39,7 @@ #include "reds.h" // compatibility for *BSD systems -#ifndef TCP_CORK +#if !defined(TCP_CORK) && !defined(_WIN32) #define TCP_CORK TCP_NOPUSH #endif @@ -100,6 +100,7 @@ struct RedStreamPrivate { SpiceCoreInterfaceInternal *core; }; +#ifndef _WIN32 /** * Set TCP_CORK on socket */ @@ -109,6 +110,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) { @@ -316,6 +323,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, }; @@ -358,6 +366,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 9a7cc617..ca6dc71a 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 7436df81..d64c26e8 100644 --- a/server/red-worker.c +++ b/server/red-worker.c @@ -1143,22 +1143,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 b17dc208..d658103e 100644 --- a/server/reds.c +++ b/server/reds.c @@ -2644,9 +2644,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) { @@ -2665,6 +2667,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 9888a9f0..c952ffc5 100644 --- a/server/sound.c +++ b/server/sound.c @@ -773,7 +773,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); @@ -789,7 +788,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), @@ -797,6 +797,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 211cddfa..4228be31 100644 --- a/server/stat-file.c +++ b/server/stat-file.c @@ -17,6 +17,7 @@ */ #include <config.h> +#ifndef _WIN32 #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -234,3 +235,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 607a5a5e..e331e852 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 0da5f997..e3ef7bf1 100644 --- a/server/tests/replay.c +++ b/server/tests/replay.c @@ -409,10 +409,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 \ diff --git a/tools/meson.build b/tools/meson.build index 1d78340b..8ec2cc91 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 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel