From 15da68dbded450a4d31692aaa78d5fa3b5d0c6c8 Mon Sep 17 00:00:00 2001 From: Marc-AndrĂ© Lureau Date: Mon, 2 Sep 2013 17:39:57 +0200 Subject: server/dispatcher: move worker enums to dispatcher header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Group enums with their respective struct location. Acked-by: Frediano Ziglio Acked-by: Fabiano FidĂȘncio --- server/red_dispatcher.h | 97 ++++++++++++++++++++++++++++++++++++++++++++++++- server/red_worker.h | 93 +---------------------------------------------- 2 files changed, 96 insertions(+), 94 deletions(-) diff --git a/server/red_dispatcher.h b/server/red_dispatcher.h index 320b7e33..05596a3d 100644 --- a/server/red_dispatcher.h +++ b/server/red_dispatcher.h @@ -18,10 +18,13 @@ #ifndef _H_RED_DISPATCHER #define _H_RED_DISPATCHER +#include +#include #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 ca8aadbc..c71e9c83 100644 --- a/server/red_worker.h +++ b/server/red_worker.h @@ -21,60 +21,13 @@ #include #include #include "red_common.h" +#include "red_dispatcher.h" enum { RED_WORKER_PENDING_WAKEUP, RED_WORKER_PENDING_OOM, }; -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, @@ -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 -- cgit