[Spice-devel] [PATCH spice-gtk 2/2] channel-smartcard: unref in flight messages as soon as they are send

Christophe Fergeau cfergeau at redhat.com
Mon Dec 5 03:07:22 PST 2011


s/send/sent in the subject

On Sat, Dec 03, 2011 at 03:00:23PM +0100, Hans de Goede wrote:
> This is a preparation patch for making spice_msg_out_send() take ownership
> of the passed in msg.

Have you run a test with a smartcard with this change? ACK anyway, I'm
asking to know if this needs to be tested or not :)

Christophe

> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  gtk/channel-smartcard.c |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/gtk/channel-smartcard.c b/gtk/channel-smartcard.c
> index 04815a3..a4a7c81 100644
> --- a/gtk/channel-smartcard.c
> +++ b/gtk/channel-smartcard.c
> @@ -191,7 +191,8 @@ static const spice_msg_handler smartcard_handlers[] = {
>  static void
>  smartcard_message_free(SpiceSmartcardChannelMessage *message)
>  {
> -    spice_msg_out_unref(message->message);
> +    if (message->message)
> +        spice_msg_out_unref(message->message);
>      g_slice_free(SpiceSmartcardChannelMessage, message);
>  }
>  
> @@ -266,8 +267,11 @@ smartcard_message_complete_in_flight(SpiceSmartcardChannel *channel)
>  {
>      smartcard_message_free(channel->priv->in_flight_message);
>      channel->priv->in_flight_message = g_queue_pop_head(channel->priv->message_queue);
> -    if (channel->priv->in_flight_message != NULL)
> +    if (channel->priv->in_flight_message != NULL) {
>          spice_msg_out_send(channel->priv->in_flight_message->message);
> +        spice_msg_out_unref(channel->priv->in_flight_message->message);
> +        channel->priv->in_flight_message->message = NULL;
> +    }
>  }
>  
>  static void smartcard_message_send(SpiceSmartcardChannel *channel,
> @@ -291,7 +295,9 @@ static void smartcard_message_send(SpiceSmartcardChannel *channel,
>      if (channel->priv->in_flight_message == NULL) {
>          g_return_if_fail(g_queue_is_empty(channel->priv->message_queue));
>          channel->priv->in_flight_message = message;
> -        spice_msg_out_send(msg_out);
> +        spice_msg_out_send(channel->priv->in_flight_message->message);
> +        spice_msg_out_unref(channel->priv->in_flight_message->message);
> +        channel->priv->in_flight_message->message = NULL;
>      } else {
>          g_queue_push_tail(channel->priv->message_queue, message);
>      }
> -- 
> 1.7.7.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20111205/6f5f7509/attachment.pgp>


More information about the Spice-devel mailing list