[Spice-commits] server/red_dispatcher.h server/red_worker.h

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Oct 22 02:07:23 PDT 2015


 server/red_dispatcher.h |   97 +++++++++++++++++++++++++++++++++++++++++++++++-
 server/red_worker.h     |   93 ----------------------------------------------
 2 files changed, 96 insertions(+), 94 deletions(-)

New commits:
commit 15da68dbded450a4d31692aaa78d5fa3b5d0c6c8
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Mon Sep 2 17:39:57 2013 +0200

    server/dispatcher: move worker enums to dispatcher header
    
    Group enums with their respective struct location.
    
    Acked-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Fabiano FidĂȘncio <fabiano at fidencio.org>

diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h
index 320b7e3..05596a3 100644
--- a/server/red_dispatcher.h
+++ b/server/red_dispatcher.h
@@ -18,10 +18,13 @@
 #ifndef _H_RED_DISPATCHER
 #define _H_RED_DISPATCHER
 
+#include <unistd.h>
+#include <errno.h>
 #include "red_channel.h"
 
-struct RedChannelClient;
-struct RedDispatcher;
+typedef struct RedDispatcher RedDispatcher;
+typedef struct RedChannelClient RedChannelClient;
+
 typedef struct AsyncCommand AsyncCommand;
 
 void red_dispatcher_init(QXLInstance *qxl);
@@ -41,6 +44,96 @@ struct Dispatcher *red_dispatcher_get_dispatcher(struct RedDispatcher *);
 int red_dispatcher_use_client_monitors_config(void);
 void red_dispatcher_client_monitors_config(VDAgentMonitorsConfig *monitors_config);
 
+typedef uint32_t RedWorkerMessage;
+
+static inline void send_data(int fd, void *in_buf, int n)
+{
+    uint8_t *buf = in_buf;
+    do {
+        int now;
+        if ((now = write(fd, buf, n)) == -1) {
+            if (errno == EINTR) {
+                continue;
+            }
+            spice_error("%s", strerror(errno));
+        }
+        buf += now;
+        n -= now;
+    } while (n);
+}
+
+static inline void write_message(int fd, RedWorkerMessage *message)
+{
+    send_data(fd, message, sizeof(RedWorkerMessage));
+}
+
+static inline void receive_data(int fd, void *in_buf, int n)
+{
+    uint8_t *buf = in_buf;
+    do {
+        int now;
+        if ((now = read(fd, buf, n)) == -1) {
+            if (errno == EINTR) {
+                continue;
+            }
+            spice_error("%s", strerror(errno));
+        }
+        buf += now;
+        n -= now;
+    } while (n);
+}
+
+static inline void read_message(int fd, RedWorkerMessage *message)
+{
+    receive_data(fd, message, sizeof(RedWorkerMessage));
+}
+
+enum {
+    RED_WORKER_MESSAGE_NOP,
+    RED_WORKER_MESSAGE_UPDATE,
+    RED_WORKER_MESSAGE_WAKEUP,
+    RED_WORKER_MESSAGE_OOM,
+    RED_WORKER_MESSAGE_READY,
+    RED_WORKER_MESSAGE_DISPLAY_CONNECT,
+    RED_WORKER_MESSAGE_DISPLAY_DISCONNECT,
+    RED_WORKER_MESSAGE_DISPLAY_MIGRATE,
+    RED_WORKER_MESSAGE_START,
+    RED_WORKER_MESSAGE_STOP,
+    RED_WORKER_MESSAGE_CURSOR_CONNECT,
+    RED_WORKER_MESSAGE_CURSOR_DISCONNECT,
+    RED_WORKER_MESSAGE_CURSOR_MIGRATE,
+    RED_WORKER_MESSAGE_SET_COMPRESSION,
+    RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
+    RED_WORKER_MESSAGE_SET_MOUSE_MODE,
+    RED_WORKER_MESSAGE_ADD_MEMSLOT,
+    RED_WORKER_MESSAGE_DEL_MEMSLOT,
+    RED_WORKER_MESSAGE_RESET_MEMSLOTS,
+    RED_WORKER_MESSAGE_DESTROY_SURFACES,
+    RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE,
+    RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE,
+    RED_WORKER_MESSAGE_RESET_CURSOR,
+    RED_WORKER_MESSAGE_RESET_IMAGE_CACHE,
+    RED_WORKER_MESSAGE_DESTROY_SURFACE_WAIT,
+    RED_WORKER_MESSAGE_LOADVM_COMMANDS,
+    /* async commands */
+    RED_WORKER_MESSAGE_UPDATE_ASYNC,
+    RED_WORKER_MESSAGE_ADD_MEMSLOT_ASYNC,
+    RED_WORKER_MESSAGE_DESTROY_SURFACES_ASYNC,
+    RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE_ASYNC,
+    RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE_ASYNC,
+    RED_WORKER_MESSAGE_DESTROY_SURFACE_WAIT_ASYNC,
+    /* suspend/windows resolution change command */
+    RED_WORKER_MESSAGE_FLUSH_SURFACES_ASYNC,
+
+    RED_WORKER_MESSAGE_DISPLAY_CHANNEL_CREATE,
+    RED_WORKER_MESSAGE_CURSOR_CHANNEL_CREATE,
+
+    RED_WORKER_MESSAGE_MONITORS_CONFIG_ASYNC,
+    RED_WORKER_MESSAGE_DRIVER_UNLOAD,
+
+    RED_WORKER_MESSAGE_COUNT // LAST
+};
+
 typedef struct RedWorkerMessageDisplayConnect {
     RedClient * client;
     RedsStream * stream;
diff --git a/server/red_worker.h b/server/red_worker.h
index ca8aadb..c71e9c8 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -21,6 +21,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include "red_common.h"
+#include "red_dispatcher.h"
 
 enum {
     RED_WORKER_PENDING_WAKEUP,
@@ -28,54 +29,6 @@ enum {
 };
 
 enum {
-    RED_WORKER_MESSAGE_NOP,
-    RED_WORKER_MESSAGE_UPDATE,
-    RED_WORKER_MESSAGE_WAKEUP,
-    RED_WORKER_MESSAGE_OOM,
-    RED_WORKER_MESSAGE_READY,
-    RED_WORKER_MESSAGE_DISPLAY_CONNECT,
-    RED_WORKER_MESSAGE_DISPLAY_DISCONNECT,
-    RED_WORKER_MESSAGE_DISPLAY_MIGRATE,
-    RED_WORKER_MESSAGE_START,
-    RED_WORKER_MESSAGE_STOP,
-    RED_WORKER_MESSAGE_CURSOR_CONNECT,
-    RED_WORKER_MESSAGE_CURSOR_DISCONNECT,
-    RED_WORKER_MESSAGE_CURSOR_MIGRATE,
-    RED_WORKER_MESSAGE_SET_COMPRESSION,
-    RED_WORKER_MESSAGE_SET_STREAMING_VIDEO,
-    RED_WORKER_MESSAGE_SET_MOUSE_MODE,
-    RED_WORKER_MESSAGE_ADD_MEMSLOT,
-    RED_WORKER_MESSAGE_DEL_MEMSLOT,
-    RED_WORKER_MESSAGE_RESET_MEMSLOTS,
-    RED_WORKER_MESSAGE_DESTROY_SURFACES,
-    RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE,
-    RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE,
-    RED_WORKER_MESSAGE_RESET_CURSOR,
-    RED_WORKER_MESSAGE_RESET_IMAGE_CACHE,
-    RED_WORKER_MESSAGE_DESTROY_SURFACE_WAIT,
-    RED_WORKER_MESSAGE_LOADVM_COMMANDS,
-    /* async commands */
-    RED_WORKER_MESSAGE_UPDATE_ASYNC,
-    RED_WORKER_MESSAGE_ADD_MEMSLOT_ASYNC,
-    RED_WORKER_MESSAGE_DESTROY_SURFACES_ASYNC,
-    RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE_ASYNC,
-    RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE_ASYNC,
-    RED_WORKER_MESSAGE_DESTROY_SURFACE_WAIT_ASYNC,
-    /* suspend/windows resolution change command */
-    RED_WORKER_MESSAGE_FLUSH_SURFACES_ASYNC,
-
-    RED_WORKER_MESSAGE_DISPLAY_CHANNEL_CREATE,
-    RED_WORKER_MESSAGE_CURSOR_CHANNEL_CREATE,
-
-    RED_WORKER_MESSAGE_MONITORS_CONFIG_ASYNC,
-    RED_WORKER_MESSAGE_DRIVER_UNLOAD,
-
-    RED_WORKER_MESSAGE_COUNT // LAST
-};
-
-typedef uint32_t RedWorkerMessage;
-
-enum {
     RED_RENDERER_INVALID,
     RED_RENDERER_SW,
     RED_RENDERER_OGL_PBUF,
@@ -84,8 +37,6 @@ enum {
     RED_RENDERER_LAST
 };
 
-typedef struct RedDispatcher RedDispatcher;
-
 typedef struct WorkerInitData {
     struct QXLInstance *qxl;
     int id;
@@ -107,46 +58,4 @@ typedef struct WorkerInitData {
 
 void *red_worker_main(void *arg);
 
-static inline void send_data(int fd, void *in_buf, int n)
-{
-    uint8_t *buf = in_buf;
-    do {
-        int now;
-        if ((now = write(fd, buf, n)) == -1) {
-            if (errno == EINTR) {
-                continue;
-            }
-            spice_error("%s", strerror(errno));
-        }
-        buf += now;
-        n -= now;
-    } while (n);
-}
-
-static inline void write_message(int fd, RedWorkerMessage *message)
-{
-    send_data(fd, message, sizeof(RedWorkerMessage));
-}
-
-static inline void receive_data(int fd, void *in_buf, int n)
-{
-    uint8_t *buf = in_buf;
-    do {
-        int now;
-        if ((now = read(fd, buf, n)) == -1) {
-            if (errno == EINTR) {
-                continue;
-            }
-            spice_error("%s", strerror(errno));
-        }
-        buf += now;
-        n -= now;
-    } while (n);
-}
-
-static inline void read_message(int fd, RedWorkerMessage *message)
-{
-    receive_data(fd, message, sizeof(RedWorkerMessage));
-}
-
 #endif


More information about the Spice-commits mailing list