diff options
author | Dan Winship <danw@gnome.org> | 2013-09-29 09:06:37 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2013-09-29 10:45:13 -0400 |
commit | 96da2df64c9dd8cc52e97ce73e54615d6b520664 (patch) | |
tree | 9a3047c4779b22af29f179a6195daa5db4ba2003 /libsoup | |
parent | a5d3351caf88824db7de968f312565851d47840a (diff) | |
download | libsoup-96da2df64c9dd8cc52e97ce73e54615d6b520664.tar.gz |
Fix soup_client_input_stream_close to not block
Closing a SoupClientInputStream for a message that hadn't been
completely read was trying to read to the end of the message first.
Fix it to just cancel the read instead.
Also fix a few tests that were implicitly assuming the old behavior.
https://bugzilla.gnome.org/show_bug.cgi?id=695652
Diffstat (limited to 'libsoup')
-rw-r--r-- | libsoup/soup-client-input-stream.c | 12 | ||||
-rw-r--r-- | libsoup/soup-message-io.c | 10 |
2 files changed, 17 insertions, 5 deletions
diff --git a/libsoup/soup-client-input-stream.c b/libsoup/soup-client-input-stream.c index d73fb007..87fa49d6 100644 --- a/libsoup/soup-client-input-stream.c +++ b/libsoup/soup-client-input-stream.c @@ -187,11 +187,13 @@ soup_client_input_stream_close_async (GInputStream *stream, task = g_task_new (stream, cancellable, callback, user_data); g_task_set_priority (task, priority); - source = soup_message_io_get_source (cistream->priv->msg, - cancellable, NULL, NULL); - - g_task_attach_source (task, source, (GSourceFunc) close_async_ready); - g_source_unref (source); + if (close_async_ready (cistream->priv->msg, task) == G_SOURCE_CONTINUE) { + source = soup_message_io_get_source (cistream->priv->msg, + cancellable, NULL, NULL); + + g_task_attach_source (task, source, (GSourceFunc) close_async_ready); + g_source_unref (source); + } } static gboolean diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c index f5f4c514..16a74e11 100644 --- a/libsoup/soup-message-io.c +++ b/libsoup/soup-message-io.c @@ -982,8 +982,18 @@ soup_message_io_run_until_finish (SoupMessage *msg, GCancellable *cancellable, GError **error) { + SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); + SoupMessageIOData *io = priv->io_data; + g_object_ref (msg); + if (io) { + g_return_if_fail (io->mode == SOUP_MESSAGE_IO_CLIENT); + + if (io->read_state < SOUP_MESSAGE_IO_STATE_BODY_DONE) + io->read_state = SOUP_MESSAGE_IO_STATE_BODY_DONE; + } + if (!io_run_until (msg, blocking, SOUP_MESSAGE_IO_STATE_DONE, SOUP_MESSAGE_IO_STATE_DONE, |