From 7d399c61a971568cab55f4e46d8805f64ec66ac7 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Wed, 4 Dec 2013 11:33:34 -0500 Subject: [PATCH] file transfer: fix double async callback This was a combination of two issues. operation_failed() is a function that reports failure of async operations via returning an error on the GSimpleAsyncResult stored in self->priv->result. It was being called in the failure case from splice_stream_ready_cb() which is not a function that should be returning an async result (as evidenced by its successful path not doing so). This was compounded by the fact that the GSimpleAsyncResult for tp_file_transfer_channel_provide_file_async() was leaked after a successful completion and was therefore still in the self->priv->result variable. Remove the erroneous call to operation_failed() and add an assert to enforce that operation_failed() is only called in the case of self->priv->result being set. Fix the leak of the result in accept_or_provide_file_cb(), ensuring the field is properly cleared. --- telepathy-glib/file-transfer-channel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/telepathy-glib/file-transfer-channel.c b/telepathy-glib/file-transfer-channel.c index d3067da..1109056 100644 --- a/telepathy-glib/file-transfer-channel.c +++ b/telepathy-glib/file-transfer-channel.c @@ -184,6 +184,8 @@ static void operation_failed (TpFileTransferChannel *self, GError *error) { + g_assert (self->priv->result != NULL); + g_simple_async_result_take_error (self->priv->result, error); g_simple_async_result_complete_in_idle (self->priv->result); tp_clear_object (&self->priv->result); @@ -224,7 +226,6 @@ splice_stream_ready_cb (GObject *output, if (error != NULL && !g_cancellable_is_cancelled (self->priv->cancellable)) { DEBUG ("splice operation failed: %s", error->message); - operation_failed (self, error); } g_io_stream_close_async (self->priv->stream, G_PRIORITY_DEFAULT, @@ -1171,6 +1172,7 @@ accept_or_provide_file_cb (TpChannel *proxy, } g_simple_async_result_complete_in_idle (self->priv->result); + tp_clear_object (&self->priv->result); } static gboolean -- 1.8.4.2