mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-05 22:21:40 +00:00
channel: More removal of IncomingHandlerInterface vfuncs
This commit removes IncomingHandlerInterface::on_error and IncomingHandlerInterface::on_input. As with previous commits, these vfuncs are always calling the method, and RedChannel::init sets them to point to RedChannelClient methods, which RedChannelClient is then going to call indirectly through the IncomingHandlerInterface instance. This commit changes this to direct calls to the corresponding methods. Signed-off-by: Christophe Fergeau <cfergeau@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
725c5fd323
commit
99641c6874
@ -384,7 +384,7 @@ static void red_channel_client_data_sent(void *opaque, int n)
|
||||
red_channel_on_output(channel, n);
|
||||
}
|
||||
|
||||
void red_channel_client_on_input(void *opaque, int n)
|
||||
static void red_channel_client_data_read(void *opaque, int n)
|
||||
{
|
||||
RedChannelClient *rcc = opaque;
|
||||
|
||||
@ -1147,10 +1147,10 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
|
||||
handler->header.data + handler->header_pos,
|
||||
handler->header.header_size - handler->header_pos);
|
||||
if (bytes_read == -1) {
|
||||
handler->cb->on_error(handler->opaque);
|
||||
red_channel_client_disconnect(handler->opaque);
|
||||
return;
|
||||
}
|
||||
handler->cb->on_input(handler->opaque, bytes_read);
|
||||
red_channel_client_data_read(handler->opaque, bytes_read);
|
||||
handler->header_pos += bytes_read;
|
||||
|
||||
if (handler->header_pos != handler->header.header_size) {
|
||||
@ -1165,7 +1165,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
|
||||
handler->msg = red_channel_client_alloc_msg_buf(handler->opaque, msg_type, msg_size);
|
||||
if (handler->msg == NULL) {
|
||||
spice_printerr("ERROR: channel refused to allocate buffer.");
|
||||
handler->cb->on_error(handler->opaque);
|
||||
red_channel_client_disconnect(handler->opaque);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1176,10 +1176,10 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
|
||||
if (bytes_read == -1) {
|
||||
red_channel_client_release_msg_buf(handler->opaque, msg_type, msg_size,
|
||||
handler->msg);
|
||||
handler->cb->on_error(handler->opaque);
|
||||
red_channel_client_disconnect(handler->opaque);
|
||||
return;
|
||||
}
|
||||
handler->cb->on_input(handler->opaque, bytes_read);
|
||||
red_channel_client_data_read(handler->opaque, bytes_read);
|
||||
handler->msg_pos += bytes_read;
|
||||
if (handler->msg_pos != msg_size) {
|
||||
return;
|
||||
@ -1195,7 +1195,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
|
||||
red_channel_client_release_msg_buf(handler->opaque,
|
||||
msg_type, msg_size,
|
||||
handler->msg);
|
||||
handler->cb->on_error(handler->opaque);
|
||||
red_channel_client_disconnect(handler->opaque);
|
||||
return;
|
||||
}
|
||||
ret_handle = handler->cb->handle_message(handler->opaque, msg_type,
|
||||
@ -1211,7 +1211,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
|
||||
handler->header_pos = 0;
|
||||
|
||||
if (!ret_handle) {
|
||||
handler->cb->on_error(handler->opaque);
|
||||
red_channel_client_disconnect(handler->opaque);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,8 +175,6 @@ void red_channel_client_disconnect_if_pending_send(RedChannelClient *rcc);
|
||||
|
||||
RedChannel* red_channel_client_get_channel(RedChannelClient *rcc);
|
||||
|
||||
void red_channel_client_on_input(void *opaque, int n);
|
||||
|
||||
void red_channel_client_semi_seamless_migration_complete(RedChannelClient *rcc);
|
||||
void red_channel_client_init_outgoing_messages_window(RedChannelClient *rcc);
|
||||
|
||||
|
||||
@ -198,11 +198,6 @@ red_channel_finalize(GObject *object)
|
||||
G_OBJECT_CLASS(red_channel_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void red_channel_client_default_peer_on_error(RedChannelClient *rcc)
|
||||
{
|
||||
red_channel_client_disconnect(rcc);
|
||||
}
|
||||
|
||||
void red_channel_on_output(RedChannel *self, int n)
|
||||
{
|
||||
#ifdef RED_STATISTICS
|
||||
@ -325,11 +320,6 @@ red_channel_init(RedChannel *self)
|
||||
red_channel_set_common_cap(self, SPICE_COMMON_CAP_MINI_HEADER);
|
||||
self->priv->thread_id = pthread_self();
|
||||
|
||||
// TODO: send incoming_cb as parameters instead of duplicating?
|
||||
self->priv->incoming_cb.on_error =
|
||||
(on_incoming_error_proc)red_channel_client_default_peer_on_error;
|
||||
self->priv->incoming_cb.on_input = red_channel_client_on_input;
|
||||
|
||||
self->priv->client_cbs.connect = red_channel_client_default_connect;
|
||||
self->priv->client_cbs.disconnect = red_channel_client_default_disconnect;
|
||||
self->priv->client_cbs.migrate = red_channel_client_default_migrate;
|
||||
|
||||
@ -61,15 +61,11 @@ struct SpiceDataHeaderOpaque {
|
||||
|
||||
typedef int (*handle_message_proc)(void *opaque,
|
||||
uint16_t type, uint32_t size, uint8_t *msg);
|
||||
typedef void (*on_incoming_error_proc)(void *opaque);
|
||||
typedef void (*on_input_proc)(void *opaque, int n);
|
||||
|
||||
typedef struct IncomingHandlerInterface {
|
||||
on_incoming_error_proc on_error; // recv error or handle_message error
|
||||
// 'parser' is optional and will not be used if NULL
|
||||
spice_parse_channel_func_t parser;
|
||||
handle_message_proc handle_message;
|
||||
on_input_proc on_input;
|
||||
} IncomingHandlerInterface;
|
||||
|
||||
typedef struct RedChannel RedChannel;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user