[PATCH spice-server v5 08/18] reds: Use socket compatibility layer (close -> socket_close)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 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 181ed283c..6b5d0b2e0 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 0aae3589f..71a03bd0b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -108,6 +108,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);
 }
 
@@ -2661,7 +2662,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;
         }
 
@@ -2709,7 +2710,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);
@@ -2718,7 +2719,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;
@@ -2756,14 +2757,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

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]