server/dispatcher: move worker enums to dispatcher header

Group enums with their respective struct location.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Fabiano Fidêncio <fabiano@fidencio.org>
This commit is contained in:
Marc-André Lureau 2013-09-02 17:39:57 +02:00 committed by Frediano Ziglio
parent 31292412c9
commit 15da68dbde
2 changed files with 96 additions and 94 deletions

View File

@ -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;

View File

@ -21,60 +21,13 @@
#include <unistd.h>
#include <errno.h>
#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