summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-11-08 13:45:51 +0000
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-11-11 10:50:53 +0000
commit69cc5afe3dc1d47742337c8463cf379aae85c2a7 (patch)
tree6d385d2087c7e19099e59bc61d0ded53777e6258
parent9f3ea8363e20f0e1b7efd810c4560cfe9a1becbd (diff)
ft-channel: cancel splice operation on channel invalidation
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--telepathy-glib/file-transfer-channel.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/telepathy-glib/file-transfer-channel.c b/telepathy-glib/file-transfer-channel.c
index 522ce7784..7c1cd1da0 100644
--- a/telepathy-glib/file-transfer-channel.c
+++ b/telepathy-glib/file-transfer-channel.c
@@ -134,6 +134,7 @@ struct _TpFileTransferChannelPrivate
GValue *access_control_param;
GSimpleAsyncResult *result;
+ GCancellable *cancellable;
};
enum /* properties */
@@ -173,12 +174,13 @@ splice_stream_ready_cb (GObject *output,
g_output_stream_splice_finish (G_OUTPUT_STREAM (output), result,
&error);
- if (error != NULL)
+ if (error != NULL && !g_cancellable_is_cancelled (self->priv->cancellable))
{
DEBUG ("splice operation failed: %s", error->message);
operation_failed (self, error);
- g_clear_error (&error);
}
+
+ g_clear_error (&error);
}
static void
@@ -227,7 +229,7 @@ client_socket_connected (TpFileTransferChannel *self)
g_output_stream_splice_async (stream, self->priv->in_stream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- G_PRIORITY_DEFAULT, NULL,
+ G_PRIORITY_DEFAULT, self->priv->cancellable,
splice_stream_ready_cb, self);
}
else
@@ -239,7 +241,7 @@ client_socket_connected (TpFileTransferChannel *self)
g_output_stream_splice_async (self->priv->out_stream, stream,
G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- G_PRIORITY_DEFAULT, NULL,
+ G_PRIORITY_DEFAULT, self->priv->cancellable,
splice_stream_ready_cb, self);
}
}
@@ -391,6 +393,17 @@ out:
g_simple_async_result_complete (result);
}
+static void
+invalidated_cb (TpFileTransferChannel *self,
+ guint domain,
+ gint code,
+ gchar *message,
+ gpointer user_data)
+{
+ /* stop splicing */
+ g_cancellable_cancel (self->priv->cancellable);
+}
+
/* Private methods */
static void
@@ -558,6 +571,10 @@ tp_file_transfer_channel_constructed (GObject *obj)
DEBUG ("Channel %s doesn't have Chan.I.FileTransfer.Metadata.Metadata "
"in its immutable properties", tp_proxy_get_object_path (self));
}
+
+ self->priv->cancellable = g_cancellable_new ();
+ g_signal_connect (self, "invalidated",
+ G_CALLBACK (invalidated_cb), NULL);
}
static void
@@ -652,6 +669,7 @@ tp_file_transfer_channel_dispose (GObject *obj)
tp_clear_pointer (&self->priv->date, g_date_time_unref);
g_clear_object (&self->priv->file);
+ g_clear_object (&self->priv->cancellable);
if (self->priv->remote_address != NULL)
{