[Spice-devel] [PATCH spice-gtk 2/2] channel-smartcard: unref in flight messages as soon as they are send
Hans de Goede
hdegoede at redhat.com
Sat Dec 3 06:00:23 PST 2011
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 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
More information about the Spice-devel
mailing list