[libgdata] core: Ensure that _gdata_service_actually_send_message() never returns NONE
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] core: Ensure that _gdata_service_actually_send_message() never returns NONE
- Date: Mon, 20 Dec 2010 13:50:14 +0000 (UTC)
commit d968510805686fba3f0b6d1318db4402b10fbcbe
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Dec 20 10:05:21 2010 +0000
core: Ensure that _gdata_service_actually_send_message() never returns NONE
If the message was cancelled before _gdata_service_actually_send_message()
was called, it wasn't previously getting the correct status code
(SOUP_STATUS_CANCELLED) set.
gdata/gdata-service.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c
index 2410dd8..a3ea251 100644
--- a/gdata/gdata-service.c
+++ b/gdata/gdata-service.c
@@ -1023,9 +1023,14 @@ _gdata_service_actually_send_message (SoupSession *session, SoupMessage *message
}
/* Only send the message if it hasn't already been cancelled. There is no race condition here for the above reasons: if the cancellable has
- * been cancelled, it's because it was cancelled before we called g_cancellable_connect(). */
+ * been cancelled, it's because it was cancelled before we called g_cancellable_connect().
+ *
+ * Otherwise, manually set the message's status code to SOUP_STATUS_CANCELLED, as the message was cancelled before even being queued to be
+ * sent. */
if (cancellable == NULL || g_cancellable_is_cancelled (cancellable) == FALSE)
soup_session_send_message (session, message);
+ else
+ soup_message_set_status (message, SOUP_STATUS_CANCELLED);
/* Clean up the cancellation code */
if (cancellable != NULL)
@@ -1035,9 +1040,8 @@ _gdata_service_actually_send_message (SoupSession *session, SoupMessage *message
g_cancellable_disconnect (cancellable, cancel_signal);
/* Set the cancellation error if applicable */
- if (message->status_code == SOUP_STATUS_NONE)
- g_assert (cancellable == NULL || g_cancellable_set_error_if_cancelled (cancellable, error) == TRUE);
- else if (message->status_code == SOUP_STATUS_CANCELLED)
+ g_assert (message->status_code != SOUP_STATUS_NONE);
+ if (message->status_code == SOUP_STATUS_CANCELLED)
g_assert (cancellable != NULL && g_cancellable_set_error_if_cancelled (cancellable, error) == TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]