[Spice-devel] [PATCH spice-server 2/2] red-channel: Move byte statistic to RedChannelClient
Jonathon Jongsma
jjongsma at redhat.com
Fri Mar 3 22:07:55 UTC 2017
I like to see that dependency removed.
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
On Fri, 2017-03-03 at 16:45 +0000, Frediano Ziglio wrote:
> As the counters are shared there is no reason why not
> handling the byte count from RedChannelClient directly.
> This remove a dependency and avoid some function calls.
> The only visible difference at user level is that the
> counters are created when a client connects.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/red-channel-client.c | 7 +++----
> server/red-channel.c | 8 --------
> server/red-channel.h | 1 -
> 3 files changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/server/red-channel-client.c b/server/red-channel-
> client.c
> index 80dfdbb..35bd01a 100644
> --- a/server/red-channel-client.c
> +++ b/server/red-channel-client.c
> @@ -150,6 +150,7 @@ struct RedChannelClientPrivate
> OutgoingMessageBuffer outgoing;
>
> RedStatCounter out_messages;
> + RedStatCounter out_bytes;
> };
>
> static const SpiceDataHeaderOpaque full_header_wrapper;
> @@ -380,6 +381,7 @@ static void
> red_channel_client_constructed(GObject *object)
> RedsState* reds = red_channel_get_server(channel);
> const RedStatNode *node = red_channel_get_stat_node(channel);
> stat_init_counter(&self->priv->out_messages, reds, node,
> "out_messages", TRUE);
> + stat_init_counter(&self->priv->out_bytes, reds, node,
> "out_bytes", TRUE);
> }
>
> static void red_channel_client_class_init(RedChannelClientClass
> *klass)
> @@ -458,13 +460,10 @@ RedChannel*
> red_channel_client_get_channel(RedChannelClient *rcc)
>
> static void red_channel_client_data_sent(RedChannelClient *rcc, int
> n)
> {
> - RedChannel *channel = red_channel_client_get_channel(rcc);
> -
> if (rcc->priv->connectivity_monitor.timer) {
> rcc->priv->connectivity_monitor.out_bytes += n;
> }
> - /* TODO: use a signal rather than a hardcoded call to a
> RedChannel callback? */
> - red_channel_on_output(channel, n);
> + stat_inc_counter(rcc->priv->out_bytes, n);
> }
>
> static void red_channel_client_data_read(RedChannelClient *rcc, int
> n)
> diff --git a/server/red-channel.c b/server/red-channel.c
> index d78c628..3808155 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -99,7 +99,6 @@ struct RedChannelPrivate
> pthread_t thread_id;
> RedsState *reds;
> RedStatNode stat;
> - RedStatCounter out_bytes_counter;
> };
>
> enum {
> @@ -188,11 +187,6 @@ red_channel_finalize(GObject *object)
> G_OBJECT_CLASS(red_channel_parent_class)->finalize(object);
> }
>
> -void red_channel_on_output(RedChannel *self, int n)
> -{
> - stat_inc_counter(self->priv->out_bytes_counter, n);
> -}
> -
> static void
> red_channel_constructed(GObject *object)
> {
> @@ -370,8 +364,6 @@ void red_channel_init_stat_node(RedChannel
> *channel, const RedStatNode *parent,
>
> // TODO check not already initialized
> stat_init_node(&channel->priv->stat, channel->priv->reds,
> parent, name, TRUE);
> - stat_init_counter(&channel->priv->out_bytes_counter,
> - channel->priv->reds, &channel->priv->stat,
> "out_bytes", TRUE);
> }
>
> const RedStatNode *red_channel_get_stat_node(RedChannel *channel)
> diff --git a/server/red-channel.h b/server/red-channel.h
> index e076e2a..73bd1e1 100644
> --- a/server/red-channel.h
> +++ b/server/red-channel.h
> @@ -232,7 +232,6 @@ 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);
> const RedStatNode *red_channel_get_stat_node(RedChannel *channel);
More information about the Spice-devel
mailing list