diff options
| author | Dan Winship <danw@gnome.org> | 2015-03-01 10:34:18 -0500 |
|---|---|---|
| committer | Dan Winship <danw@gnome.org> | 2015-03-01 10:36:26 -0500 |
| commit | f428c8f511247a66fd75eebc158472fdd7c44f9a (patch) | |
| tree | 370c64394999c11e8ff7f68c0b3c49a3b91cf166 | |
| parent | 0ebeb24f7935729deb29acc54b59b4af8fec09e1 (diff) | |
| download | libsoup-f428c8f511247a66fd75eebc158472fdd7c44f9a.tar.gz | |
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.
| -rw-r--r-- | 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 ea5ddef1..62daaa05 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 |
