[gnome-online-accounts/gnome-3-6] ewsclient: Differentiate between short-circuited and cancelled messages



commit 232bffd1dae3e708f06d83fd802a2218e43ebc5d
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Dec 5 15:26:09 2012 +0100

    ewsclient: Differentiate between short-circuited and cancelled messages
    
    Since more than one message is queued, we cancel the rest if any one
    of them is successful. This short-circuiting is different from cases
    where all messages are cancelled because of a soup_session_abort
    triggered by a GCancellable.
    
    Fixes: https://bugzilla.gnome.org/689642

 src/goabackend/goaewsclient.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/goabackend/goaewsclient.c b/src/goabackend/goaewsclient.c
index caa9ca8..699f778 100644
--- a/src/goabackend/goaewsclient.c
+++ b/src/goabackend/goaewsclient.c
@@ -183,7 +183,7 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
   xmlNode *node;
 
   status = msg->status_code;
-  if (status == SOUP_STATUS_CANCELLED)
+  if (status == SOUP_STATUS_NONE)
     return;
 
   error = NULL;
@@ -200,7 +200,9 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
 
   data->msgs[idx] = NULL;
 
-  if (status != SOUP_STATUS_OK)
+  if (status == SOUP_STATUS_CANCELLED)
+    goto out;
+  else if (status != SOUP_STATUS_OK)
     {
       g_set_error (&error,
                    GOA_ERROR,
@@ -298,13 +300,14 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
            * message, the callback (ie. this function) will be invoked before
            * soup_session_cancel_message returns.
            */
-          soup_session_cancel_message (data->session, data->msgs[idx], SOUP_STATUS_CANCELLED);
+          soup_session_cancel_message (data->session, data->msgs[idx], SOUP_STATUS_NONE);
           data->msgs[idx] = NULL;
         }
     }
 
  out:
-  if (error != NULL)
+  /* error == NULL, if we are being aborted by the GCancellable */
+  if (!op_res)
     {
       for (idx = 0; idx < size; idx++)
         {
@@ -317,7 +320,8 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
               return;
             }
         }
-      g_simple_async_result_set_from_error (data->res, error);
+      if (error != NULL)
+        g_simple_async_result_set_from_error (data->res, error);
     }
   else
     g_simple_async_result_set_op_res_gboolean (data->res, op_res);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]