summaryrefslogtreecommitdiff
path: root/gio/goutputstream.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2012-04-27 09:27:38 -0400
committerDan Winship <danw@gnome.org>2012-04-27 09:27:38 -0400
commitfd3ec4df87ce05f364799b7eb8b0219420d755c4 (patch)
tree7f44a22604b21b3e13dcd969e8ab2ac2dcfa2e86 /gio/goutputstream.c
parent00285b7517a63a243a5b61b738de5eea957ae767 (diff)
downloadglib-fd3ec4df87ce05f364799b7eb8b0219420d755c4.tar.gz
Fix several recently-introduced bugs in g_output_stream_write_async()
g_output_stream_write_async() was not initializing the newly-added members of the WriteData structure, causing various problems. Also, g_input_stream_read_async() was now leaking its cancellable. Fix that as well. https://bugzilla.gnome.org/show_bug.cgi?id=674612
Diffstat (limited to 'gio/goutputstream.c')
-rw-r--r--gio/goutputstream.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index 9d3815db5..e238d8bfd 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -1273,6 +1273,14 @@ typedef struct {
} WriteData;
static void
+free_write_data (WriteData *op)
+{
+ if (op->cancellable)
+ g_object_unref (op->cancellable);
+ g_slice_free (WriteData, op);
+}
+
+static void
write_async_thread (GSimpleAsyncResult *res,
GObject *object,
GCancellable *cancellable)
@@ -1355,11 +1363,14 @@ g_output_stream_real_write_async (GOutputStream *stream,
GSimpleAsyncResult *res;
WriteData *op;
- op = g_new0 (WriteData, 1);
+ op = g_slice_new0 (WriteData);
res = g_simple_async_result_new (G_OBJECT (stream), callback, user_data, g_output_stream_real_write_async);
- g_simple_async_result_set_op_res_gpointer (res, op, g_free);
+ g_simple_async_result_set_op_res_gpointer (res, op, (GDestroyNotify) free_write_data);
op->buffer = buffer;
op->count_requested = count;
+ op->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
+ op->io_priority = io_priority;
+ op->need_idle = TRUE;
if (G_IS_POLLABLE_OUTPUT_STREAM (stream) &&
g_pollable_output_stream_can_poll (G_POLLABLE_OUTPUT_STREAM (stream)))