diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2011-08-20 17:39:06 +0100 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2011-08-20 17:44:20 +0100 |
commit | 0345885c14f2d5c1f80b6460be302adeb3e14103 (patch) | |
tree | 3fcccc1b3caad3618a9edb6d9c8f9a45edd8ad2e /gdata/gdata-service.c | |
parent | db6ee229558fcd749fc2e6ea2b2fb26bfa46d082 (diff) | |
download | libgdata-0345885c14f2d5c1f80b6460be302adeb3e14103.tar.gz |
core: Catch SOUP_STATUS_IO_ERROR and treat it as cancellation
When we cancel a request, it's (somehow) possible for libsoup to return
SOUP_STATUS_IO_ERROR instead of the (desired) SOUP_STATUS_CANCELLED. We now
catch SOUP_STATUS_IO_ERROR and, if the user requested cancellation, treat it
like a normal cancellation status.
Diffstat (limited to 'gdata/gdata-service.c')
-rw-r--r-- | gdata/gdata-service.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c index a082668b..d0e1f3ed 100644 --- a/gdata/gdata-service.c +++ b/gdata/gdata-service.c @@ -630,16 +630,22 @@ _gdata_service_actually_send_message (SoupSession *session, SoupMessage *message } /* Set the cancellation error if applicable. We can't assume that our GCancellable has been cancelled just because the message has; - * libsoup may internally cancel messages if, for example, the proxy URI of the SoupSession is changed. */ + * libsoup may internally cancel messages if, for example, the proxy URI of the SoupSession is changed. + * libsoup also sometimes seems to return a SOUP_STATUS_IO_ERROR when we cancel a message, even though we've specified SOUP_STATUS_CANCELLED + * at cancellation time. Ho Hum. */ g_assert (message->status_code != SOUP_STATUS_NONE); - if (message->status_code == SOUP_STATUS_CANCELLED) { + if (message->status_code == SOUP_STATUS_CANCELLED || + (message->status_code == SOUP_STATUS_IO_ERROR && cancellable != NULL && g_cancellable_is_cancelled (cancellable) == TRUE)) { /* We hackily create and cancel a new GCancellable so that we can set the error using it and therefore save ourselves a translatable * string and the associated maintenance. */ GCancellable *error_cancellable = g_cancellable_new (); g_cancellable_cancel (error_cancellable); g_assert (g_cancellable_set_error_if_cancelled (error_cancellable, error) == TRUE); g_object_unref (error_cancellable); + + /* As per the above comment, force the status to be SOUP_STATUS_CANCELLED. */ + soup_message_set_status (message, SOUP_STATUS_CANCELLED); } /* Free things */ |