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



commit 27e86279bbaff430fe0757f97c97c44d190b7da6
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 8f5c133..01ef1b3 100644
--- a/src/goabackend/goaewsclient.c
+++ b/src/goabackend/goaewsclient.c
@@ -179,7 +179,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;
@@ -196,7 +196,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,
@@ -284,13 +286,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++)
         {
@@ -303,7 +306,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]