[Spice-devel] [spice-server v2 03/14] channel: Rework red_channel_on_output a bit
Christophe Fergeau
cfergeau at redhat.com
Tue Feb 14 14:17:28 UTC 2017
Have the RedChannelClient callback call into a RedChannel callback
rather than doing the opposite. This will be useful in some subsequent
refactoring of this code.
Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
---
server/red-channel-client.c | 2 ++
server/red-channel.c | 9 ++-------
server/red-channel.h | 1 +
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 52dee70..cc1c846 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -376,10 +376,12 @@ RedChannel* red_channel_client_get_channel(RedChannelClient *rcc)
void red_channel_client_on_output(void *opaque, int n)
{
RedChannelClient *rcc = opaque;
+ RedChannel *channel = red_channel_client_get_channel(rcc);
if (rcc->priv->connectivity_monitor.timer) {
rcc->priv->connectivity_monitor.out_bytes += n;
}
+ red_channel_on_output(channel, n);
}
void red_channel_client_on_input(void *opaque, int n)
diff --git a/server/red-channel.c b/server/red-channel.c
index 9d492e6..b53bbcd 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -202,14 +202,9 @@ static void red_channel_client_default_peer_on_error(RedChannelClient *rcc)
red_channel_client_disconnect(rcc);
}
-static void red_channel_on_output(void *opaque, int n)
+void red_channel_on_output(RedChannel *self, int n)
{
- RedChannelClient *rcc G_GNUC_UNUSED;
- RedChannel *self G_GNUC_UNUSED;
-
- red_channel_client_on_output(opaque, n);
#ifdef RED_STATISTICS
- self = red_channel_client_get_channel((RedChannelClient *)opaque);
stat_inc_counter(self->priv->reds, self->priv->out_bytes_counter, n);
#endif
}
@@ -343,7 +338,7 @@ red_channel_init(RedChannel *self)
self->priv->outgoing_cb.on_error =
(on_outgoing_error_proc)red_channel_client_default_peer_on_error;
self->priv->outgoing_cb.on_msg_done = red_channel_client_on_out_msg_done;
- self->priv->outgoing_cb.on_output = red_channel_on_output;
+ self->priv->outgoing_cb.on_output = red_channel_client_on_output;
self->priv->client_cbs.connect = red_channel_client_default_connect;
self->priv->client_cbs.disconnect = red_channel_client_default_disconnect;
diff --git a/server/red-channel.h b/server/red-channel.h
index 0cdf564..23374b8 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -296,6 +296,7 @@ SpiceCoreInterfaceInternal* red_channel_get_core_interface(RedChannel *channel);
/* channel callback function */
int red_channel_config_socket(RedChannel *self, RedChannelClient *rcc);
void red_channel_on_disconnect(RedChannel *self, RedChannelClient *rcc);
+void red_channel_on_output(RedChannel *self, int n);
void red_channel_send_item(RedChannel *self, RedChannelClient *rcc, RedPipeItem *item);
void red_channel_reset_thread_id(RedChannel *self);
StatNodeRef red_channel_get_stat_node(RedChannel *channel);
--
2.9.3
More information about the Spice-devel
mailing list