[libsoup] soup-io-stream: fix close_async
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup-io-stream: fix close_async
- Date: Sun, 1 Mar 2015 15:39:11 +0000 (UTC)
commit f428c8f511247a66fd75eebc158472fdd7c44f9a
Author: Dan Winship <danw gnome org>
Date: Sun Mar 1 10:34:18 2015 -0500
soup-io-stream: fix close_async
It's not completely legitimate for SoupIOStream's close_async() method
to just pass the callback and user_data it receives on to its base
stream's close_async() method (and in fact, this loses horribly with
glib < 2.42 [https://bugzilla.gnome.org/show_bug.cgi?id=722723]). Fix
it to properly indirect through its own callback instead.
libsoup/soup-io-stream.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-io-stream.c b/libsoup/soup-io-stream.c
index ea5ddef..62daaa0 100644
--- a/libsoup/soup-io-stream.c
+++ b/libsoup/soup-io-stream.c
@@ -137,6 +137,21 @@ soup_io_stream_close (GIOStream *stream,
cancellable, error);
}
+static void
+close_async_complete (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GTask *task = user_data;
+ GError *error = NULL;
+
+ if (g_io_stream_close_finish (G_IO_STREAM (object), result, &error))
+ g_task_return_boolean (task, TRUE);
+ else
+ g_task_return_error (task, error);
+ g_object_unref (task);
+}
+
static void
soup_io_stream_close_async (GIOStream *stream,
int io_priority,
@@ -144,8 +159,12 @@ soup_io_stream_close_async (GIOStream *stream,
GAsyncReadyCallback callback,
gpointer user_data)
{
+ GTask *task;
+
+ task = g_task_new (stream, cancellable, callback, user_data);
g_io_stream_close_async (SOUP_IO_STREAM (stream)->priv->base_iostream,
- io_priority, cancellable, callback, user_data);
+ io_priority, cancellable,
+ close_async_complete, task);
}
static gboolean
@@ -153,8 +172,7 @@ soup_io_stream_close_finish (GIOStream *stream,
GAsyncResult *result,
GError **error)
{
- return g_io_stream_close_finish (SOUP_IO_STREAM (stream)->priv->base_iostream,
- result, error);
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]