summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2015-10-30 11:12:01 -0500
committerFrediano Ziglio <fziglio@redhat.com>2015-10-30 17:15:18 +0000
commit2eb732bd4d7cce9ed4e93f8640b15262c90bf79a (patch)
tree81ada209a20c290d0ce916a8c7ebd3110e6bf2f1 /server
parent2d934ed82e22d3317186e5f63e28c5105b5ea2d2 (diff)
downloadspice-2eb732bd4d7cce9ed4e93f8640b15262c90bf79a.tar.gz
spice-2eb732bd4d7cce9ed4e93f8640b15262c90bf79a.tar.xz
spice-2eb732bd4d7cce9ed4e93f8640b15262c90bf79a.zip
__new_channel -> red_worker_new_channel()
Rename and lightly refactor the function that creates new common channels for RedWorker (essentially Cursor and Display channels). Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
Diffstat (limited to 'server')
-rw-r--r--server/cursor-channel.c31
-rw-r--r--server/red_worker.c59
-rw-r--r--server/red_worker.h14
3 files changed, 45 insertions, 59 deletions
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index b9842259..e8d0057d 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -354,26 +354,25 @@ static void cursor_channel_release_item(RedChannelClient *rcc, PipeItem *item, i
CursorChannel* cursor_channel_new(RedWorker *worker)
{
- CursorChannel* cursor;
+ CursorChannel *cursor_channel;
+ RedChannel *channel = NULL;
+ ChannelCbs cbs = {
+ .on_disconnect = cursor_channel_client_on_disconnect,
+ .send_item = cursor_channel_send_item,
+ .hold_item = cursor_channel_hold_pipe_item,
+ .release_item = cursor_channel_release_item
+ };
spice_info("create cursor channel");
- cursor = (CursorChannel *)__new_channel(
- worker, sizeof(CursorChannel),
- SPICE_CHANNEL_CURSOR,
- 0,
- cursor_channel_client_on_disconnect,
- cursor_channel_send_item,
- cursor_channel_hold_pipe_item,
- cursor_channel_release_item,
- red_channel_client_handle_message,
- NULL,
- NULL,
- NULL);
+ channel = red_worker_new_channel(worker, sizeof(CursorChannel),
+ SPICE_CHANNEL_CURSOR, 0,
+ &cbs, red_channel_client_handle_message);
- cursor->cursor_visible = TRUE;
- cursor->mouse_mode = SPICE_MOUSE_MODE_SERVER;
+ cursor_channel = (CursorChannel *)channel;
+ cursor_channel->cursor_visible = TRUE;
+ cursor_channel->mouse_mode = SPICE_MOUSE_MODE_SERVER;
- return cursor;
+ return cursor_channel;
}
CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient *client, RedsStream *stream,
diff --git a/server/red_worker.c b/server/red_worker.c
index 574414c1..5cb551b1 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9492,38 +9492,30 @@ DisplayChannelClient *display_channel_client_create(CommonChannel *common,
return dcc;
}
-RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_type,
- int migration_flags,
- channel_disconnect_proc on_disconnect,
- channel_send_pipe_item_proc send_item,
- channel_hold_pipe_item_proc hold_item,
- channel_release_pipe_item_proc release_item,
- channel_handle_parsed_proc handle_parsed,
- channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark,
- channel_handle_migrate_data_proc handle_migrate_data,
- channel_handle_migrate_data_get_serial_proc migrate_get_serial)
+RedChannel *red_worker_new_channel(RedWorker *worker, int size,
+ uint32_t channel_type, int migration_flags,
+ ChannelCbs *channel_cbs,
+ channel_handle_parsed_proc handle_parsed)
{
RedChannel *channel = NULL;
CommonChannel *common;
- ChannelCbs channel_cbs = { NULL, };
-
- channel_cbs.config_socket = common_channel_config_socket;
- channel_cbs.on_disconnect = on_disconnect;
- channel_cbs.send_item = send_item;
- channel_cbs.hold_item = hold_item;
- channel_cbs.release_item = release_item;
- channel_cbs.alloc_recv_buf = common_alloc_recv_buf;
- channel_cbs.release_recv_buf = common_release_recv_buf;
- channel_cbs.handle_migrate_flush_mark = handle_migrate_flush_mark;
- channel_cbs.handle_migrate_data = handle_migrate_data;
- channel_cbs.handle_migrate_data_get_serial = migrate_get_serial;
+
+ spice_return_val_if_fail(worker, NULL);
+ spice_return_val_if_fail(channel_cbs, NULL);
+ spice_return_val_if_fail(!channel_cbs->config_socket, NULL);
+ spice_return_val_if_fail(!channel_cbs->alloc_recv_buf, NULL);
+ spice_return_val_if_fail(!channel_cbs->release_recv_buf, NULL);
+
+ channel_cbs->config_socket = common_channel_config_socket;
+ channel_cbs->alloc_recv_buf = common_alloc_recv_buf;
+ channel_cbs->release_recv_buf = common_release_recv_buf;
channel = red_channel_create_parser(size, &worker_core,
channel_type, worker->qxl->id,
TRUE /* handle_acks */,
spice_get_client_channel_parser(channel_type, NULL),
handle_parsed,
- &channel_cbs,
+ channel_cbs,
migration_flags);
common = (CommonChannel *)channel;
if (!channel) {
@@ -9673,25 +9665,26 @@ static void display_channel_release_item(RedChannelClient *rcc, PipeItem *item,
static void display_channel_create(RedWorker *worker, int migrate)
{
DisplayChannel *display_channel;
+ ChannelCbs cbs = {
+ .on_disconnect = display_channel_client_on_disconnect,
+ .send_item = display_channel_send_item,
+ .hold_item = display_channel_hold_pipe_item,
+ .release_item = display_channel_release_item,
+ .handle_migrate_flush_mark = display_channel_handle_migrate_mark,
+ .handle_migrate_data = display_channel_handle_migrate_data,
+ .handle_migrate_data_get_serial = display_channel_handle_migrate_data_get_serial
+ };
if (worker->display_channel) {
return;
}
spice_info("create display channel");
- if (!(worker->display_channel = (DisplayChannel *)__new_channel(
+ if (!(worker->display_channel = (DisplayChannel *)red_worker_new_channel(
worker, sizeof(*display_channel),
SPICE_CHANNEL_DISPLAY,
SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER,
- display_channel_client_on_disconnect,
- display_channel_send_item,
- display_channel_hold_pipe_item,
- display_channel_release_item,
- display_channel_handle_message,
- display_channel_handle_migrate_mark,
- display_channel_handle_migrate_data,
- display_channel_handle_migrate_data_get_serial
- ))) {
+ &cbs, display_channel_handle_message))) {
spice_warning("failed to create display channel");
return;
}
diff --git a/server/red_worker.h b/server/red_worker.h
index 795959dc..76502b6e 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -118,16 +118,10 @@ RedWorker* red_worker_new(QXLInstance *qxl, RedDispatcher *red_dispatcher);
bool red_worker_run(RedWorker *worker);
QXLInstance* red_worker_get_qxl(RedWorker *worker);
-RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_type,
- int migration_flags,
- channel_disconnect_proc on_disconnect,
- channel_send_pipe_item_proc send_item,
- channel_hold_pipe_item_proc hold_item,
- channel_release_pipe_item_proc release_item,
- channel_handle_parsed_proc handle_parsed,
- channel_handle_migrate_flush_mark_proc handle_migrate_flush_mark,
- channel_handle_migrate_data_proc handle_migrate_data,
- channel_handle_migrate_data_get_serial_proc migrate_get_serial);
+RedChannel *red_worker_new_channel(RedWorker *worker, int size,
+ uint32_t channel_type, int migration_flags,
+ ChannelCbs *channel_cbs,
+ channel_handle_parsed_proc handle_parsed);
CommonChannelClient *common_channel_new_client(CommonChannel *common,
int size,