mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-27 03:18:59 +00:00
windows: Disable code not working on Windows
- 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@redhat.com> Acked-by: Victor Toso <victortoso@redhat.com>
This commit is contained in:
parent
c8ab3c2c98
commit
524acca643
@ -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);
|
||||
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 \
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user