[Spice-devel] [PATCH spice-server v4 10/20] reds: Use socket compatibility layer
Frediano Ziglio
fziglio at redhat.com
Wed Feb 6 13:58:46 UTC 2019
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red-common.h | 1 +
server/reds.c | 11 ++++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/server/red-common.h b/server/red-common.h
index 181ed283..6b5d0b2e 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -35,6 +35,7 @@
#include "spice.h"
#include "utils.h"
+#include "sys-socket.h"
#define SPICE_UPCAST(type, ptr) \
(verify_expr(SPICE_OFFSETOF(type, base) == 0,SPICE_CONTAINEROF(ptr, type, base)))
diff --git a/server/reds.c b/server/reds.c
index 97023b38..3404d5a2 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -114,6 +114,7 @@ static void adapter_timer_remove(const SpiceCoreInterfaceInternal *iface, SpiceT
static SpiceWatch *adapter_watch_add(const SpiceCoreInterfaceInternal *iface,
int fd, int event_mask, SpiceWatchFunc func, void *opaque)
{
+ // note: Qemu API is fine having a SOCKET on Windows
return iface->public_interface->watch_add(fd, event_mask, func, opaque);
}
@@ -2667,7 +2668,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
len = SUN_LEN(&local);
if (bind(slisten, (struct sockaddr *)&local, len) == -1) {
perror("bind");
- close(slisten);
+ socket_close(slisten);
return -1;
}
@@ -2715,7 +2716,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
freeaddrinfo(res);
goto listen;
}
- close(slisten);
+ socket_close(slisten);
}
spice_warning("binding socket to %s:%d failed", addr, portnr);
freeaddrinfo(res);
@@ -2724,7 +2725,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
listen:
if (listen(slisten, SOMAXCONN) != 0) {
spice_warning("listen: %s", strerror(errno));
- close(slisten);
+ socket_close(slisten);
return -1;
}
return slisten;
@@ -2762,14 +2763,14 @@ static void reds_cleanup_net(SpiceServer *reds)
if (reds->listen_socket != -1) {
reds_core_watch_remove(reds, reds->listen_watch);
if (reds->config->spice_listen_socket_fd != reds->listen_socket) {
- close(reds->listen_socket);
+ socket_close(reds->listen_socket);
}
reds->listen_watch = NULL;
reds->listen_socket = -1;
}
if (reds->secure_listen_socket != -1) {
reds_core_watch_remove(reds, reds->secure_listen_watch);
- close(reds->secure_listen_socket);
+ socket_close(reds->secure_listen_socket);
reds->secure_listen_watch = NULL;
reds->secure_listen_socket = -1;
}
--
2.20.1
More information about the Spice-devel
mailing list