[Spice-commits] 5 commits - server/dispatcher.c server/event-loop.c server/net-utils.c server/red-channel-client.c server/red-qxl.c server/reds.c server/reds.h server/red-stream.c server/sound.c server/spice-core.h server/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 31 11:13:06 UTC 2019


 server/dispatcher.c              |    2 ++
 server/event-loop.c              |    5 +++++
 server/net-utils.c               |    2 ++
 server/red-channel-client.c      |    6 ++++--
 server/red-qxl.c                 |    1 -
 server/red-stream.c              |    6 ++++--
 server/reds.c                    |   12 ++++++++----
 server/reds.h                    |    2 +-
 server/sound.c                   |    2 ++
 server/spice-core.h              |    6 ++++++
 server/tests/replay.c            |   13 +++++++++++--
 server/tests/test-display-base.c |    2 ++
 server/tests/test-listen.c       |   10 ++++++++++
 server/tests/test-playback.c     |    1 -
 14 files changed, 57 insertions(+), 13 deletions(-)

New commits:
commit 9bf95486e5e63ea66093e6d642ea9494551c8c76
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Jun 24 19:29:45 2018 +0100

    event-loop: Port to Windows
    
    Use g_io_channel_win32_new_socket instead of g_io_channel_unix_new
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/event-loop.c b/server/event-loop.c
index 413102e8..a6a6e634 100644
--- a/server/event-loop.c
+++ b/server/event-loop.c
@@ -123,6 +123,7 @@ static gboolean watch_func(GIOChannel *source, GIOCondition condition,
                            gpointer data)
 {
     SpiceWatch *watch = data;
+    // this works also under Windows despite the name
     int fd = g_io_channel_unix_get_fd(source);
 
     watch->func(fd, giocondition_to_spice_event(condition), watch->opaque);
@@ -162,7 +163,11 @@ static SpiceWatch *watch_add(const SpiceCoreInterfaceInternal *iface,
 
     watch = g_new0(SpiceWatch, 1);
     watch->context = iface->main_context;
+#ifndef _WIN32
     watch->channel = g_io_channel_unix_new(fd);
+#else
+    watch->channel = g_io_channel_win32_new_socket(fd);
+#endif
     watch->func = func;
     watch->opaque = opaque;
 
commit ec71c795f3958ba50e97300a420fedcb83796626
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Jun 24 19:30:14 2018 +0100

    replay: Port to Windows
    
    Client process termination did not work for Windows, used Win32
    APIs.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/tests/replay.c b/server/tests/replay.c
index efd67a3d..f7d26fec 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -210,15 +210,22 @@ static int req_display_notification(QXLInstance *qin)
 
 static void end_replay(void)
 {
-    int child_status;
-
     /* FIXME: wait threads and end cleanly */
     spice_replay_free(replay);
 
     if (client_pid) {
         g_debug("kill %" G_PID_FORMAT, client_pid);
+#ifndef _WIN32
+        int child_status;
+
         kill(client_pid, SIGINT);
         waitpid(client_pid, &child_status, 0);
+#else
+        TerminateProcess(client_pid, 0);
+        WaitForSingleObject(client_pid, INFINITE);
+#endif
+        g_spawn_close_pid(client_pid);
+        client_pid = 0;
     }
 }
 
commit aed85f0ff122ddab853e83dc9597376c407644c7
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun Jun 24 21:40:37 2018 +0100

    test-listen: Exclude Unix sockets part under Windows
    
    Windows does not support Unix sockets.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/tests/test-listen.c b/server/tests/test-listen.c
index 640e8f12..2fd4b5a3 100644
--- a/server/tests/test-listen.c
+++ b/server/tests/test-listen.c
@@ -27,7 +27,9 @@
 #include <stdint.h>
 #include <string.h>
 #include <gio/gio.h>
+#ifndef _WIN32
 #include <gio/gunixsocketaddress.h>
+#endif
 
 #include "test-glib-compat.h"
 
@@ -211,7 +213,11 @@ static GThread *fake_client_new(GThreadFunc thread_func,
     ThreadData *thread_data = g_new0(ThreadData, 1);
 
     if (port == -1) {
+#ifndef _WIN32
         thread_data->connectable = G_SOCKET_CONNECTABLE(g_unix_socket_address_new(hostname));
+#else
+        g_assert_not_reached();
+#endif
     } else {
         g_assert_cmpuint(port, >, 0);
         g_assert_cmpuint(port, <, 65536);
@@ -317,6 +323,7 @@ static void test_connect_plain_and_tls(void)
     spice_server_destroy(server);
 }
 
+#ifndef _WIN32
 static void test_connect_unix(void)
 {
     GThread *thread;
@@ -342,6 +349,7 @@ static void test_connect_unix(void)
     test_event_loop_destroy(&event_loop);
     spice_server_destroy(server);
 }
+#endif
 
 static void test_connect_ko(void)
 {
@@ -365,7 +373,9 @@ int main(int argc, char **argv)
     g_test_add_func("/server/listen/connect_plain", test_connect_plain);
     g_test_add_func("/server/listen/connect_tls", test_connect_tls);
     g_test_add_func("/server/listen/connect_both", test_connect_plain_and_tls);
+#ifndef _WIN32
     g_test_add_func("/server/listen/connect_unix", test_connect_unix);
+#endif
     g_test_add_func("/server/listen/connect_ko", test_connect_ko);
 
     return g_test_run();
commit b69fe6cb331d3a8e82b27b14369d8b1c2cf1ccf0
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sat Dec 15 15:45:10 2018 +0000

    reds: Explicitly include inttypes.h
    
    MingW does not include this header while including stdint.h so
    on Windows you need to include it.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/reds.h b/server/reds.h
index 2ad09ada..e3641fa1 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -19,6 +19,7 @@
 #define REDS_H_
 
 #include <stdint.h>
+#include <inttypes.h>
 #include <spice/vd_agent.h>
 #include <common/marshaller.h>
 #include <common/messages.h>
commit f8e8ac4910656cd948e418fcf255a8267c73f9c6
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Jun 20 14:23:44 2018 +0100

    windows: Do not include headers not available on Windows
    
    This is a preparatory patch for next portability patches
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>

diff --git a/server/dispatcher.c b/server/dispatcher.c
index 48dc915a..3e27f2c2 100644
--- a/server/dispatcher.c
+++ b/server/dispatcher.c
@@ -24,7 +24,9 @@
 #include <string.h>
 #include <pthread.h>
 #include <fcntl.h>
+#ifndef _WIN32
 #include <poll.h>
+#endif
 
 #include "dispatcher.h"
 
diff --git a/server/net-utils.c b/server/net-utils.c
index ca8a4e7f..802509a4 100644
--- a/server/net-utils.c
+++ b/server/net-utils.c
@@ -24,11 +24,13 @@
 #include <stdbool.h>
 #include <string.h>
 #include <sys/types.h>
+#ifndef _WIN32
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <sys/socket.h>
+#endif
 
 #include <common/log.h>
 
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index b3a6ec12..375a60b3 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -22,12 +22,14 @@
 #include <glib.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#ifndef _WIN32
+#include <netinet/in.h>
+#include <netinet/tcp.h>
 #include <sys/ioctl.h>
+#endif
 #ifdef HAVE_LINUX_SOCKIOS_H
 #include <linux/sockios.h> /* SIOCOUTQ */
 #endif
diff --git a/server/red-qxl.c b/server/red-qxl.c
index ddb98afb..0dd26b22 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -24,7 +24,6 @@
 #include <errno.h>
 #include <string.h>
 #include <pthread.h>
-#include <sys/socket.h>
 #include <inttypes.h>
 
 #include <spice/qxl_dev.h>
diff --git a/server/red-stream.c b/server/red-stream.c
index 311387c2..55ad170f 100644
--- a/server/red-stream.c
+++ b/server/red-stream.c
@@ -20,11 +20,13 @@
 #endif
 
 #include <errno.h>
-#include <netdb.h>
 #include <unistd.h>
-#include <sys/socket.h>
 #include <fcntl.h>
+#ifndef _WIN32
+#include <netdb.h>
+#include <sys/socket.h>
 #include <netinet/tcp.h>
+#endif
 
 #include <glib.h>
 
diff --git a/server/reds.c b/server/reds.c
index d7a71dc1..87715c48 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -22,16 +22,21 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <limits.h>
+#include <pthread.h>
+#include <ctype.h>
+#ifndef _WIN32
 #include <sys/socket.h>
 #include <sys/uio.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <limits.h>
-#include <pthread.h>
 #include <sys/mman.h>
-#include <ctype.h>
+#include <sys/un.h>
+#else
+#include <ws2tcpip.h>
+#endif
 
 #include <openssl/err.h>
 
@@ -40,7 +45,6 @@
 #endif
 
 #include <glib.h>
-#include <sys/un.h>
 
 #include <spice/protocol.h>
 #include <spice/vd_agent.h>
diff --git a/server/reds.h b/server/reds.h
index 4778366a..2ad09ada 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -19,7 +19,6 @@
 #define REDS_H_
 
 #include <stdint.h>
-#include <sys/uio.h>
 #include <spice/vd_agent.h>
 #include <common/marshaller.h>
 #include <common/messages.h>
diff --git a/server/sound.c b/server/sound.c
index 8cdb7d71..44b27dec 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -23,10 +23,12 @@
 #include <errno.h>
 #include <limits.h>
 #include <sys/types.h>
+#ifndef _WIN32
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
+#endif
 
 #include <common/generated_server_marshallers.h>
 #include <common/snd_codec.h>
diff --git a/server/spice-core.h b/server/spice-core.h
index 3d5c83bf..d77c4f9e 100644
--- a/server/spice-core.h
+++ b/server/spice-core.h
@@ -23,7 +23,13 @@
 #endif
 
 #include <stdint.h>
+#ifndef _WIN32
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#include <windows.h>
+typedef int socklen_t;
+#endif
 #include <spice/qxl_dev.h>
 #include <spice/vd_agent.h>
 #include <spice/macros.h>
diff --git a/server/tests/replay.c b/server/tests/replay.c
index 095b112e..efd67a3d 100644
--- a/server/tests/replay.c
+++ b/server/tests/replay.c
@@ -30,7 +30,9 @@
 #include <signal.h>
 #include <unistd.h>
 #include <pthread.h>
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 #include <fcntl.h>
 #include <glib.h>
 #include <pthread.h>
diff --git a/server/tests/test-display-base.c b/server/tests/test-display-base.c
index aa59b443..31d856ae 100644
--- a/server/tests/test-display-base.c
+++ b/server/tests/test-display-base.c
@@ -21,8 +21,10 @@
 #include <string.h>
 #include <stdio.h>
 #include <unistd.h>
+#ifndef _WIN32
 #include <sys/wait.h>
 #include <sys/select.h>
+#endif
 #include <sys/types.h>
 #include <getopt.h>
 #include <pthread.h>
diff --git a/server/tests/test-playback.c b/server/tests/test-playback.c
index acd085db..290c8609 100644
--- a/server/tests/test-playback.c
+++ b/server/tests/test-playback.c
@@ -17,7 +17,6 @@
 */
 #include <config.h>
 #include <stdio.h>
-#include <sys/select.h>
 #include <sys/time.h>
 #include <math.h>
 


More information about the Spice-commits mailing list