[Spice-devel] [PATCH spice-gtk 3/9] channel-smartcard: unref in flight messages as soon as they are send
Christophe Fergeau
cfergeau at redhat.com
Thu Dec 15 09:23:04 PST 2011
ACK
On Wed, Dec 14, 2011 at 03:14:03PM +0100, Hans de Goede wrote:
> This is a preparation patch for making spice_msg_out_send() take ownership
> of the passed in msg.
>
> 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 64fc06e..1df91ce 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);
> }
>
> @@ -268,8 +269,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,
> @@ -293,7 +297,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/20111215/12274451/attachment-0001.pgp>
More information about the Spice-devel
mailing list