[Spice-devel] [spice-server v2 06/14] channel: More removal of IncomingHandlerInterface vfuncs
Christophe Fergeau
cfergeau at redhat.com
Tue Feb 14 14:17:31 UTC 2017
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 at redhat.com>
---
server/red-channel-client.c | 16 ++++++++--------
server/red-channel-client.h | 2 --
server/red-channel.c | 10 ----------
server/red-channel.h | 4 ----
4 files changed, 8 insertions(+), 24 deletions(-)
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 9b7b818..fc82faa 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -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;
}
}
diff --git a/server/red-channel-client.h b/server/red-channel-client.h
index 9e2bf73..4f1d481 100644
--- a/server/red-channel-client.h
+++ b/server/red-channel-client.h
@@ -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);
diff --git a/server/red-channel.c b/server/red-channel.c
index 52902d0..f7cf589 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -196,11 +196,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
@@ -323,11 +318,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;
diff --git a/server/red-channel.h b/server/red-channel.h
index d373b88..25ae1a2 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -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;
--
2.9.3
More information about the Spice-devel
mailing list