summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2011-08-03 15:43:02 +0300
committerAlon Levy <alevy@redhat.com>2011-08-23 18:23:46 +0300
commit812d01c06090f14ccb65e9a3b81df311c51e4b26 (patch)
tree673f86f7619dca9f611ac038e45e488ba7f97ee8 /server
parent67671b26097a0d629a42356b22690c8b34db51a5 (diff)
downloadspice-812d01c06090f14ccb65e9a3b81df311c51e4b26.tar.gz
spice-812d01c06090f14ccb65e9a3b81df311c51e4b26.tar.xz
spice-812d01c06090f14ccb65e9a3b81df311c51e4b26.zip
server/red_channel.c: pack all channel callbacks to ChannelCbs
Diffstat (limited to 'server')
-rw-r--r--server/inputs_channel.c23
-rw-r--r--server/main_channel.c24
-rw-r--r--server/red_channel.c83
-rw-r--r--server/red_channel.h48
-rw-r--r--server/red_tunnel_worker.c23
-rw-r--r--server/red_worker.c27
-rw-r--r--server/smartcard.c20
-rw-r--r--server/usbredir.c20
8 files changed, 127 insertions, 141 deletions
diff --git a/server/inputs_channel.c b/server/inputs_channel.c
index b8d7801b..e6af0d58 100644
--- a/server/inputs_channel.c
+++ b/server/inputs_channel.c
@@ -510,23 +510,26 @@ static void inputs_link(Channel *channel, RedClient *client,
ASSERT(channel->data == g_inputs_channel);
if (channel->data == NULL) {
+ ChannelCbs channel_cbs;
+
+ memset(&channel_cbs, sizeof(channel_cbs), 0);
+
+ channel_cbs.config_socket = inputs_channel_config_socket;
+ channel_cbs.disconnect = inputs_channel_disconnect;
+ channel_cbs.send_item = inputs_channel_send_item;
+ channel_cbs.hold_item = inputs_channel_hold_pipe_item;
+ channel_cbs.release_item = inputs_channel_release_pipe_item;
+ channel_cbs.alloc_recv_buf = inputs_channel_alloc_msg_rcv_buf;
+ channel_cbs.release_recv_buf = inputs_channel_release_msg_rcv_buf;
+
red_printf("inputs channel create");
channel->data = g_inputs_channel = (InputsChannel*)red_channel_create_parser(
sizeof(InputsChannel), core, migration, FALSE /* handle_acks */
- ,inputs_channel_config_socket
- ,inputs_channel_disconnect
,spice_get_client_channel_parser(SPICE_CHANNEL_INPUTS, NULL)
,inputs_channel_handle_parsed
- ,inputs_channel_alloc_msg_rcv_buf
- ,inputs_channel_release_msg_rcv_buf
- ,inputs_channel_hold_pipe_item
- ,inputs_channel_send_item
- ,inputs_channel_release_pipe_item
,inputs_channel_on_error
,inputs_channel_on_error
- ,NULL
- ,NULL
- ,NULL);
+ ,&channel_cbs);
ASSERT(channel->data);
}
red_printf("inputs channel client create");
diff --git a/server/main_channel.c b/server/main_channel.c
index 3337c469..54b3dff4 100644
--- a/server/main_channel.c
+++ b/server/main_channel.c
@@ -937,23 +937,27 @@ MainChannelClient *main_channel_link(Channel *channel, RedClient *client,
MainChannelClient *mcc;
if (channel->data == NULL) {
+ ChannelCbs channel_cbs;
+
+ channel_cbs.config_socket = main_channel_config_socket;
+ channel_cbs.disconnect = main_channel_client_disconnect;
+ channel_cbs.send_item = main_channel_send_item;
+ channel_cbs.hold_item = main_channel_hold_pipe_item;
+ channel_cbs.release_item = main_channel_release_pipe_item;
+ channel_cbs.alloc_recv_buf = main_channel_alloc_msg_rcv_buf;
+ channel_cbs.release_recv_buf = main_channel_release_msg_rcv_buf;
+ channel_cbs.handle_migrate_flush_mark = main_channel_handle_migrate_flush_mark;
+ channel_cbs.handle_migrate_data = main_channel_handle_migrate_data;
+ channel_cbs.handle_migrate_data_get_serial = main_channel_handle_migrate_data_get_serial;
+
red_printf("create main channel");
channel->data = red_channel_create_parser(
sizeof(MainChannel), core, migration, FALSE /* handle_acks */
- ,main_channel_config_socket
- ,main_channel_client_disconnect
,spice_get_client_channel_parser(SPICE_CHANNEL_MAIN, NULL)
,main_channel_handle_parsed
- ,main_channel_alloc_msg_rcv_buf
- ,main_channel_release_msg_rcv_buf
- ,main_channel_hold_pipe_item
- ,main_channel_send_item
- ,main_channel_release_pipe_item
,main_channel_on_error
,main_channel_on_error
- ,main_channel_handle_migrate_flush_mark
- ,main_channel_handle_migrate_data
- ,main_channel_handle_migrate_data_get_serial);
+ ,&channel_cbs);
ASSERT(channel->data);
}
// TODO - migration - I removed it from channel creation, now put it
diff --git a/server/red_channel.c b/server/red_channel.c
index b5a0330e..e31f1481 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -223,7 +223,7 @@ static void red_channel_client_on_output(void *opaque, int n)
void red_channel_client_default_peer_on_error(RedChannelClient *rcc)
{
- rcc->channel->disconnect(rcc);
+ rcc->channel->channel_cbs.disconnect(rcc);
}
static void red_channel_peer_on_incoming_error(RedChannelClient *rcc)
@@ -316,7 +316,7 @@ static void red_channel_client_send_item(RedChannelClient *rcc, PipeItem *item)
handled = FALSE;
}
if (!handled) {
- rcc->channel->send_item(rcc, item);
+ rcc->channel->channel_cbs.send_item(rcc, item);
}
}
@@ -332,7 +332,7 @@ static void red_channel_client_release_item(RedChannelClient *rcc, PipeItem *ite
handled = FALSE;
}
if (!handled) {
- rcc->channel->release_item(rcc, item, item_pushed);
+ rcc->channel->channel_cbs.release_item(rcc, item, item_pushed);
}
}
@@ -397,7 +397,7 @@ RedChannelClient *red_channel_client_create(
rcc->outgoing.cb = &channel->outgoing_cb;
rcc->outgoing.pos = 0;
rcc->outgoing.size = 0;
- if (!channel->config_socket(rcc)) {
+ if (!channel->channel_cbs.config_socket(rcc)) {
goto error;
}
@@ -420,40 +420,32 @@ error:
RedChannel *red_channel_create(int size,
SpiceCoreInterface *core,
int migrate, int handle_acks,
- channel_configure_socket_proc config_socket,
- channel_disconnect_proc disconnect,
channel_handle_message_proc handle_message,
- channel_alloc_msg_recv_buf_proc alloc_recv_buf,
- channel_release_msg_recv_buf_proc release_recv_buf,
- channel_hold_pipe_item_proc hold_item,
- channel_send_pipe_item_proc send_item,
- channel_release_pipe_item_proc release_item,
- 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 handle_migrate_data_get_serial)
+ ChannelCbs *channel_cbs)
{
RedChannel *channel;
ASSERT(size >= sizeof(*channel));
- ASSERT(config_socket && disconnect && handle_message && alloc_recv_buf &&
- release_item);
+ ASSERT(channel_cbs->config_socket && channel_cbs->disconnect && handle_message &&
+ channel_cbs->alloc_recv_buf && channel_cbs->release_item);
channel = spice_malloc0(size);
channel->handle_acks = handle_acks;
- channel->disconnect = disconnect;
- channel->send_item = send_item;
- channel->release_item = release_item;
- channel->hold_item = hold_item;
- channel->handle_migrate_flush_mark = handle_migrate_flush_mark;
- channel->handle_migrate_data = handle_migrate_data;
- channel->handle_migrate_data_get_serial = handle_migrate_data_get_serial;
- channel->config_socket = config_socket;
+ channel->channel_cbs.disconnect = channel_cbs->disconnect;
+ channel->channel_cbs.send_item = channel_cbs->send_item;
+ channel->channel_cbs.release_item = channel_cbs->release_item;
+ channel->channel_cbs.hold_item = channel_cbs->hold_item;
+ channel->channel_cbs.handle_migrate_flush_mark = channel_cbs->handle_migrate_flush_mark;
+ channel->channel_cbs.handle_migrate_data = channel_cbs->handle_migrate_data;
+ channel->channel_cbs.handle_migrate_data_get_serial = channel_cbs->handle_migrate_data_get_serial;
+ channel->channel_cbs.config_socket = channel_cbs->config_socket;
channel->core = core;
channel->migrate = migrate;
ring_init(&channel->clients);
- channel->incoming_cb.alloc_msg_buf = (alloc_msg_recv_buf_proc)alloc_recv_buf;
- channel->incoming_cb.release_msg_buf = (release_msg_recv_buf_proc)release_recv_buf;
+ // TODO: send incoming_cb as parameters instead of duplicating?
+ channel->incoming_cb.alloc_msg_buf = (alloc_msg_recv_buf_proc)channel_cbs->alloc_recv_buf;
+ channel->incoming_cb.release_msg_buf = (release_msg_recv_buf_proc)channel_cbs->release_recv_buf;
channel->incoming_cb.handle_message = (handle_message_proc)handle_message;
channel->incoming_cb.on_error =
(on_incoming_error_proc)red_channel_client_default_peer_on_error;
@@ -478,26 +470,15 @@ static int do_nothing_handle_message(RedChannelClient *rcc, SpiceDataHeader *hea
RedChannel *red_channel_create_parser(int size,
SpiceCoreInterface *core,
int migrate, int handle_acks,
- channel_configure_socket_proc config_socket,
- channel_disconnect_proc disconnect,
spice_parse_channel_func_t parser,
- channel_handle_parsed_proc handle_parsed,
- channel_alloc_msg_recv_buf_proc alloc_recv_buf,
- channel_release_msg_recv_buf_proc release_recv_buf,
- channel_hold_pipe_item_proc hold_item,
- channel_send_pipe_item_proc send_item,
- channel_release_pipe_item_proc release_item,
+ channel_handle_parsed_proc handle_parsed,
channel_on_incoming_error_proc incoming_error,
channel_on_outgoing_error_proc outgoing_error,
- 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 handle_migrate_data_get_serial)
+ ChannelCbs *channel_cbs)
{
RedChannel *channel = red_channel_create(size,
- core, migrate, handle_acks, config_socket, disconnect,
- do_nothing_handle_message, alloc_recv_buf, release_recv_buf, hold_item,
- send_item, release_item, handle_migrate_flush_mark, handle_migrate_data,
- handle_migrate_data_get_serial);
+ core, migrate, handle_acks, do_nothing_handle_message,
+ channel_cbs);
if (channel == NULL) {
return NULL;
@@ -629,7 +610,7 @@ void red_channel_push(RedChannel *channel)
RING_FOREACH_SAFE(link, next, &channel->clients) {
rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link);
if (rcc->stream == NULL) {
- rcc->channel->disconnect(rcc);
+ rcc->channel->channel_cbs.disconnect(rcc);
} else {
red_channel_client_push(rcc);
}
@@ -657,8 +638,8 @@ void red_channel_init_outgoing_messages_window(RedChannel *channel)
static void red_channel_handle_migrate_flush_mark(RedChannelClient *rcc)
{
- if (rcc->channel->handle_migrate_flush_mark) {
- rcc->channel->handle_migrate_flush_mark(rcc);
+ if (rcc->channel->channel_cbs.handle_migrate_flush_mark) {
+ rcc->channel->channel_cbs.handle_migrate_flush_mark(rcc);
}
}
@@ -671,13 +652,13 @@ static void red_channel_handle_migrate_flush_mark(RedChannelClient *rcc)
// So need to make all the handlers work with per channel/client data (what data exactly?)
static void red_channel_handle_migrate_data(RedChannelClient *rcc, uint32_t size, void *message)
{
- if (!rcc->channel->handle_migrate_data) {
+ if (!rcc->channel->channel_cbs.handle_migrate_data) {
return;
}
ASSERT(red_channel_client_get_message_serial(rcc) == 0);
red_channel_client_set_message_serial(rcc,
- rcc->channel->handle_migrate_data_get_serial(rcc, size, message));
- rcc->channel->handle_migrate_data(rcc, size, message);
+ rcc->channel->channel_cbs.handle_migrate_data_get_serial(rcc, size, message));
+ rcc->channel->channel_cbs.handle_migrate_data(rcc, size, message);
}
int red_channel_client_handle_message(RedChannelClient *rcc, uint32_t size,
@@ -731,7 +712,7 @@ void red_channel_client_init_send_data(RedChannelClient *rcc, uint16_t msg_type,
rcc->send_data.header->type = msg_type;
rcc->send_data.item = item;
if (item) {
- rcc->channel->hold_item(rcc, item);
+ rcc->channel->channel_cbs.hold_item(rcc, item);
}
}
@@ -922,7 +903,7 @@ void red_channel_client_disconnect(RedChannelClient *rcc)
red_printf("%p (channel %p)", rcc, rcc->channel);
if (rcc->send_data.item) {
- rcc->channel->release_item(rcc, rcc->send_data.item, FALSE);
+ rcc->channel->channel_cbs.release_item(rcc, rcc->send_data.item, FALSE);
}
red_channel_client_pipe_clear(rcc);
reds_stream_free(rcc->stream);
@@ -1144,7 +1125,7 @@ void red_client_destroy(RedClient *client)
// some channels may be in other threads, so disconnection
// is not synchronous.
rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link);
- rcc->channel->disconnect(rcc); // this may call another thread. it also frees. (eventually - doesn't have to be in sync)
+ rcc->channel->channel_cbs.disconnect(rcc); // this may call another thread. it also frees. (eventually - doesn't have to be in sync)
}
free(client);
}
@@ -1159,7 +1140,7 @@ void red_client_disconnect(RedClient *client)
// some channels may be in other threads, so disconnection
// is not synchronous.
rcc = SPICE_CONTAINEROF(link, RedChannelClient, client_link);
- rcc->channel->disconnect(rcc);
+ rcc->channel->channel_cbs.disconnect(rcc);
}
}
diff --git a/server/red_channel.h b/server/red_channel.h
index 652673b5..996623bb 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -138,6 +138,23 @@ typedef uint64_t (*channel_handle_migrate_data_proc)(RedChannelClient *base,
typedef uint64_t (*channel_handle_migrate_data_get_serial_proc)(RedChannelClient *base,
uint32_t size, void *message);
+/*
+ * callbacks that are triggered from channel client stream events.
+ * They are called from the thread that listen to the stream events.
+ */
+typedef struct {
+ channel_configure_socket_proc config_socket;
+ channel_disconnect_proc disconnect;
+ channel_send_pipe_item_proc send_item;
+ channel_hold_pipe_item_proc hold_item;
+ channel_release_pipe_item_proc release_item;
+ channel_alloc_msg_recv_buf_proc alloc_recv_buf;
+ channel_release_msg_recv_buf_proc release_recv_buf;
+ 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 handle_migrate_data_get_serial;
+} ChannelCbs;
+
struct RedChannelClient {
RingItem channel_link;
RingItem client_link;
@@ -179,11 +196,7 @@ struct RedChannel {
OutgoingHandlerInterface outgoing_cb;
IncomingHandlerInterface incoming_cb;
- channel_configure_socket_proc config_socket;
- channel_disconnect_proc disconnect;
- channel_send_pipe_item_proc send_item;
- channel_hold_pipe_item_proc hold_item;
- channel_release_pipe_item_proc release_item;
+ ChannelCbs channel_cbs;
/* Stuff below added for Main and Inputs channels switch to RedChannel
* (might be removed later) */
@@ -191,9 +204,6 @@ struct RedChannel {
channel_on_outgoing_error_proc on_outgoing_error;
int shut; /* signal channel is to be closed */
- 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 handle_migrate_data_get_serial;
#ifdef RED_STATISTICS
uint64_t *out_bytes_counter;
#endif
@@ -204,37 +214,19 @@ struct RedChannel {
RedChannel *red_channel_create(int size,
SpiceCoreInterface *core,
int migrate, int handle_acks,
- channel_configure_socket_proc config_socket,
- channel_disconnect_proc disconnect,
channel_handle_message_proc handle_message,
- channel_alloc_msg_recv_buf_proc alloc_recv_buf,
- channel_release_msg_recv_buf_proc release_recv_buf,
- channel_hold_pipe_item_proc hold_item,
- channel_send_pipe_item_proc send_item,
- channel_release_pipe_item_proc release_item,
- 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 handle_migrate_data_get_serial);
+ ChannelCbs *channel_cbs);
/* alternative constructor, meant for marshaller based (inputs,main) channels,
* will become default eventually */
RedChannel *red_channel_create_parser(int size,
SpiceCoreInterface *core,
int migrate, int handle_acks,
- channel_configure_socket_proc config_socket,
- channel_disconnect_proc disconnect,
spice_parse_channel_func_t parser,
channel_handle_parsed_proc handle_parsed,
- channel_alloc_msg_recv_buf_proc alloc_recv_buf,
- channel_release_msg_recv_buf_proc release_recv_buf,
- channel_hold_pipe_item_proc hold_item,
- channel_send_pipe_item_proc send_item,
- channel_release_pipe_item_proc release_item,
channel_on_incoming_error_proc incoming_error,
channel_on_outgoing_error_proc outgoing_error,
- 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 handle_migrate_data_get_serial);
+ ChannelCbs *channel_cbs);
RedChannelClient *red_channel_client_create(int size, RedChannel *channel, RedClient *client,
RedsStream *stream);
diff --git a/server/red_tunnel_worker.c b/server/red_tunnel_worker.c
index 38e654e0..79cb8546 100644
--- a/server/red_tunnel_worker.c
+++ b/server/red_tunnel_worker.c
@@ -3448,25 +3448,28 @@ static void handle_tunnel_channel_link(Channel *channel, RedClient *client,
TunnelChannelClient *tcc;
TunnelWorker *worker = (TunnelWorker *)channel->data;
RedChannel *tunnel_channel;
+ ChannelCbs channel_cbs = {0,};
if (worker->channel) {
tunnel_channel_disconnect(worker->channel->base.channel);
}
+ channel_cbs.config_socket = tunnel_channel_config_socket;
+ channel_cbs.disconnect = tunnel_channel_disconnect_client;
+ channel_cbs.alloc_recv_buf = tunnel_channel_alloc_msg_rcv_buf;
+ channel_cbs.release_recv_buf = tunnel_channel_release_msg_rcv_buf;
+ channel_cbs.hold_item = tunnel_channel_hold_pipe_item;
+ channel_cbs.send_item = tunnel_channel_send_item;
+ channel_cbs.release_item = tunnel_channel_release_pipe_item;
+ channel_cbs.handle_migrate_flush_mark = tunnel_channel_handle_migrate_mark;
+ channel_cbs.handle_migrate_data = tunnel_channel_handle_migrate_data;
+ channel_cbs.handle_migrate_data_get_serial = tunnel_channel_handle_migrate_data_get_serial;
+
tunnel_channel = red_channel_create(sizeof(RedChannel),
worker->core_interface,
migration, TRUE,
- tunnel_channel_config_socket,
- tunnel_channel_disconnect_client,
tunnel_channel_handle_message,
- tunnel_channel_alloc_msg_rcv_buf,
- tunnel_channel_release_msg_rcv_buf,
- tunnel_channel_hold_pipe_item,
- tunnel_channel_send_item,
- tunnel_channel_release_pipe_item,
- tunnel_channel_handle_migrate_mark,
- tunnel_channel_handle_migrate_data,
- tunnel_channel_handle_migrate_data_get_serial);
+ &channel_cbs);
if (!tunnel_channel) {
return;
diff --git a/server/red_worker.c b/server/red_worker.c
index dc51aebd..4347d243 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9502,23 +9502,26 @@ static RedChannel *__new_channel(RedWorker *worker, int size, uint32_t channel_i
{
RedChannel *channel = NULL;
CommonChannel *common;
+ ChannelCbs channel_cbs;
+
+ channel_cbs.config_socket = common_channel_config_socket;
+ channel_cbs.disconnect = 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 = handle_migrate_data_get_serial;
channel = red_channel_create_parser(size, &worker_core, migrate,
TRUE /* handle_acks */,
- common_channel_config_socket,
- disconnect,
spice_get_client_channel_parser(channel_id, NULL),
handle_parsed,
- common_alloc_recv_buf,
- common_release_recv_buf,
- hold_item,
- send_item,
- release_item,
on_incoming_error,
on_outgoing_error,
- handle_migrate_flush_mark,
- handle_migrate_data,
- handle_migrate_data_get_serial);
+ &channel_cbs);
common = (CommonChannel *)channel;
if (!channel) {
goto error;
@@ -10061,7 +10064,7 @@ static void red_wait_pipe_item_sent(RedChannelClient *rcc, PipeItem *item)
}
red_printf("");
- channel->hold_item(rcc, item);
+ channel->channel_cbs.hold_item(rcc, item);
end_time = red_now() + CHANNEL_PUSH_TIMEOUT;
@@ -10086,7 +10089,7 @@ static void red_wait_pipe_item_sent(RedChannelClient *rcc, PipeItem *item)
red_wait_outgoing_item(rcc);
}
}
- channel->release_item(rcc, item, FALSE);
+ channel->channel_cbs.release_item(rcc, item, FALSE);
}
static void surface_dirty_region_to_rects(RedSurface *surface,
diff --git a/server/smartcard.c b/server/smartcard.c
index 2a3332cc..36004f75 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -493,23 +493,23 @@ static void smartcard_link(Channel *channel, RedClient *client,
int num_caps, uint32_t *caps)
{
RedChannelClient *rcc;
+ ChannelCbs channel_cbs;
if (!channel->data) {
+ memset(&channel_cbs, sizeof(channel_cbs), 0);
+ channel_cbs.config_socket = smartcard_channel_client_config_socket;
+ channel_cbs.disconnect = smartcard_channel_client_disconnect;
+ channel_cbs.send_item = smartcard_channel_send_item;
+ channel_cbs.hold_item = smartcard_channel_hold_pipe_item;
+ channel_cbs.release_item = smartcard_channel_release_pipe_item;
+ channel_cbs.alloc_recv_buf = smartcard_channel_alloc_msg_rcv_buf;
+ channel_cbs.release_recv_buf = smartcard_channel_release_msg_rcv_buf;
channel->data =
red_channel_create(sizeof(SmartCardChannel),
core, migration,
FALSE /* handle_acks */,
- smartcard_channel_client_config_socket,
- smartcard_channel_client_disconnect,
smartcard_channel_handle_message,
- smartcard_channel_alloc_msg_rcv_buf,
- smartcard_channel_release_msg_rcv_buf,
- smartcard_channel_hold_pipe_item,
- smartcard_channel_send_item,
- smartcard_channel_release_pipe_item,
- NULL,
- NULL,
- NULL);
+ &channel_cbs);
if (channel->data) {
red_channel_init_outgoing_messages_window((RedChannel*)channel->data);
} else {
diff --git a/server/usbredir.c b/server/usbredir.c
index 1aa89b28..50a60956 100644
--- a/server/usbredir.c
+++ b/server/usbredir.c
@@ -184,6 +184,7 @@ static void usbredir_link(Channel *channel, RedClient *client, RedsStream *strea
UsbRedirChannel *redir_chan;
SpiceCharDeviceInstance *sin;
SpiceCharDeviceInterface *sif;
+ ChannelCbs channel_cbs;
state = SPICE_CONTAINEROF(channel, UsbRedirState, channel);
sin = state->chardev_sin;
@@ -199,19 +200,18 @@ static void usbredir_link(Channel *channel, RedClient *client, RedsStream *strea
}
if (!state->red_channel) {
+ memset(&channel_cbs, sizeof(channel_cbs), 0);
+ channel_cbs.config_socket = usbredir_red_channel_config_socket;
+ channel_cbs.disconnect = usbredir_red_channel_disconnect;
+ channel_cbs.send_item = usbredir_red_channel_send_item;
+ channel_cbs.hold_item = usbredir_red_channel_hold_pipe_item;
+ channel_cbs.release_item = usbredir_red_channel_release_pipe_item;
+ channel_cbs.alloc_recv_buf = usbredir_red_channel_alloc_msg_rcv_buf;
+ channel_cbs.release_recv_buf = usbredir_red_channel_release_msg_rcv_buf;
state->red_channel = red_channel_create(sizeof(UsbRedirChannel),
core, migration, FALSE /* handle_acks */,
- usbredir_red_channel_config_socket,
- usbredir_red_channel_disconnect,
usbredir_red_channel_client_handle_message,
- usbredir_red_channel_alloc_msg_rcv_buf,
- usbredir_red_channel_release_msg_rcv_buf,
- usbredir_red_channel_hold_pipe_item,
- usbredir_red_channel_send_item,
- usbredir_red_channel_release_pipe_item,
- NULL,
- NULL,
- NULL);
+ &channel_cbs);
}
if (!state->red_channel) {
return;