[libgdata] [core] Fix cancellation races in GDataBuffer and GDataUploadStream
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] [core] Fix cancellation races in GDataBuffer and GDataUploadStream
- Date: Sat, 10 Apr 2010 17:36:52 +0000 (UTC)
commit 3cfb19d58b7a817c36938ff4168ebf4e8b962440
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 9271c41..25fe84b 100644
--- a/gdata/gdata-buffer.c
+++ b/gdata/gdata-buffer.c
@@ -232,7 +232,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 */
@@ -251,7 +251,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 b9b3086..71314ac 100644
--- a/gdata/gdata-upload-stream.c
+++ b/gdata/gdata-upload-stream.c
@@ -333,7 +333,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;
@@ -370,7 +370,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;
}
@@ -385,7 +385,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) {
@@ -429,14 +429,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]