[libgdata/libgdata-0-14] core: Disconnect a cancellable in GDataDownloadStream
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/libgdata-0-14] core: Disconnect a cancellable in GDataDownloadStream
- Date: Tue, 27 May 2014 21:14:23 +0000 (UTC)
commit 43a274295e59b64cbcd06f813507e61d7fbb9236
Author: Philip Withnall <philip tecnocode co uk>
Date: Fri May 16 10:22:17 2014 +0100
core: Disconnect a cancellable in GDataDownloadStream
Ensure to disconnect from the user-provided cancellable when finalising
a GDataDownloadStream.
Coverity issue: #59757
gdata/gdata-download-stream.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gdata/gdata-download-stream.c b/gdata/gdata-download-stream.c
index f76a59e..dde8f4a 100644
--- a/gdata/gdata-download-stream.c
+++ b/gdata/gdata-download-stream.c
@@ -160,6 +160,7 @@ struct _GDataDownloadStreamPrivate {
GThread *network_thread;
GCancellable *cancellable;
GCancellable *network_cancellable; /* see the comment in gdata_download_stream_constructor() about
the relationship between these two */
+ gulong network_cancellable_id;
gboolean finished;
GCond finished_cond;
@@ -352,7 +353,7 @@ gdata_download_stream_constructor (GType type, guint n_construct_params, GObject
/* Create a #GCancellable for the entire download operation if one wasn't specified for
#GDataDownloadStream:cancellable during construction */
if (priv->cancellable == NULL)
priv->cancellable = g_cancellable_new ();
- g_cancellable_connect (priv->cancellable, (GCallback) cancellable_cancel_cb,
priv->network_cancellable, NULL);
+ priv->network_cancellable_id = g_cancellable_connect (priv->cancellable, (GCallback)
cancellable_cancel_cb, priv->network_cancellable, NULL);
/* Build the message */
_uri = soup_uri_new (priv->download_uri);
@@ -382,8 +383,15 @@ gdata_download_stream_dispose (GObject *object)
/* Block on closing the stream */
g_input_stream_close (G_INPUT_STREAM (object), NULL, NULL);
- if (priv->cancellable != NULL)
+ if (priv->cancellable != NULL) {
+ if (priv->network_cancellable_id != 0) {
+ g_cancellable_disconnect (priv->cancellable, priv->network_cancellable_id);
+ }
+
g_object_unref (priv->cancellable);
+ }
+
+ priv->network_cancellable_id = 0;
priv->cancellable = NULL;
if (priv->network_cancellable != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]