[libgdata/libgdata-0-6] core: Fix cancellation races in GDataBuffer and GDataUploadStream



commit 3d806cc185850ea9060eb1024e90567e3f50e12c
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Apr 10 18:27:02 2010 +0100

    core: Fix cancellation races in GDataBuffer and GDataUploadStream

 gdata/gdata-buffer.c        |    4 ++--
 gdata/gdata-upload-stream.c |   10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gdata/gdata-buffer.c b/gdata/gdata-buffer.c
index 0cf4738..2fbb48f 100644
--- a/gdata/gdata-buffer.c
+++ b/gdata/gdata-buffer.c
@@ -223,7 +223,7 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
 			cancelled_data.buffer = self;
 			cancelled_data.cancelled = &cancelled;
 
-			cancelled_signal = g_signal_connect (cancellable, "cancelled", (GCallback) pop_cancelled_cb, &cancelled_data);
+			cancelled_signal = g_cancellable_connect (cancellable, (GCallback) pop_cancelled_cb, &cancelled_data, NULL);
 		}
 
 		/* Block until more data is available */
@@ -242,7 +242,7 @@ gdata_buffer_pop_data (GDataBuffer *self, guint8 *data, gsize length_requested,
 
 		/* Disconnect from the cancelled signal */
 		if (cancellable != NULL)
-			g_signal_handler_disconnect (cancellable, cancelled_signal);
+			g_cancellable_disconnect (cancellable, cancelled_signal);
 	} else {
 		return_length = length_requested;
 	}
diff --git a/gdata/gdata-upload-stream.c b/gdata/gdata-upload-stream.c
index 2fa7dc0..333157c 100644
--- a/gdata/gdata-upload-stream.c
+++ b/gdata/gdata-upload-stream.c
@@ -334,7 +334,7 @@ gdata_upload_stream_write (GOutputStream *stream, const void *buffer, gsize coun
 
 	/* Listen for cancellation events */
 	if (cancellable != NULL)
-		cancelled_signal = g_signal_connect (cancellable, "cancelled", (GCallback) write_cancelled_cb, GDATA_UPLOAD_STREAM (stream));
+		cancelled_signal = g_cancellable_connect (cancellable, (GCallback) write_cancelled_cb, GDATA_UPLOAD_STREAM (stream), NULL);
 
 	/* Set write_finished so we know if the write operation has finished before we reach write_cond */
 	priv->write_finished = FALSE;
@@ -371,7 +371,7 @@ gdata_upload_stream_write (GOutputStream *stream, const void *buffer, gsize coun
 	create_network_thread (GDATA_UPLOAD_STREAM (stream), error);
 	if (priv->network_thread == NULL) {
 		if (cancellable != NULL)
-			g_signal_handler_disconnect (cancellable, cancelled_signal);
+			g_cancellable_disconnect (cancellable, cancelled_signal);
 		return -1;
 	}
 
@@ -386,7 +386,7 @@ write:
 
 	/* Disconnect from the cancelled signal so we can't receive any more cancel events before we handle errors */
 	if (cancellable != NULL)
-		g_signal_handler_disconnect (cancellable, cancelled_signal);
+		g_cancellable_disconnect (cancellable, cancelled_signal);
 
 	/* Check for an error and return if necessary */
 	if (priv->response_error != NULL) {
@@ -430,14 +430,14 @@ gdata_upload_stream_close (GOutputStream *stream, GCancellable *cancellable, GEr
 
 		/* Allow cancellation */
 		if (cancellable != NULL)
-			cancelled_signal = g_signal_connect (cancellable, "cancelled", (GCallback) close_cancelled_cb, GDATA_UPLOAD_STREAM (stream));
+			cancelled_signal = g_cancellable_connect (cancellable, (GCallback) close_cancelled_cb, GDATA_UPLOAD_STREAM (stream), NULL);
 
 		/* Wait for the signal that we've finished */
 		g_cond_wait (priv->finished_cond, g_static_mutex_get_mutex (&(priv->response_mutex)));
 
 		/* Disconnect from the signal handler so we can't receive any more cancellation events before we handle errors*/
 		if (cancellable != NULL)
-			g_signal_handler_disconnect (cancellable, cancelled_signal);
+			g_cancellable_disconnect (cancellable, cancelled_signal);
 	}
 
 	/* Report any errors which have been set by the network thread */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]