[gnome-online-accounts] ewsclient: Only return FALSE when an error occurred



commit ed7b15bb4dd7ee14495022645d23e1cf27ce5965
Author: Erik van Pienbroek <epienbro fedoraproject org>
Date:   Fri Jun 5 17:00:02 2015 +0200

    ewsclient: Only return FALSE when an error occurred
    
    When we cancel the pending messages from the response callback of the
    first successful message, the remaining callbacks are called after the
    first one has returned to the main loop. This behaviour of the new
    SoupSession is different from the older SoupSessionAsync, where the
    callbacks were invoked before soup_session_cancel_message returned.
    
    Due to this, the status(=TRUE) set by the first successful message was
    getting lost, and we were returning FALSE even when no error was
    encountered.
    
    Save the result in the GAsyncResult to remember it across the
    callbacks.
    
    Fall out from 6c3e3c2d2d9f688157513c0f0403645c4c196754
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750392

 src/goabackend/goaewsclient.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/goabackend/goaewsclient.c b/src/goabackend/goaewsclient.c
index 4989b5a..b10d20c 100644
--- a/src/goabackend/goaewsclient.c
+++ b/src/goabackend/goaewsclient.c
@@ -221,7 +221,14 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
    * successful.
    */
   if (status == SOUP_STATUS_CANCELLED)
-    goto out;
+    {
+      /* If a previous autodiscover attempt for the same GAsyncResult
+       * was successful then no additional attempts are required and
+       * we should use the result from the earlier attempt.
+       */
+      op_res = g_simple_async_result_get_op_res_gboolean (data->res);
+      goto out;
+    }
   else if (status != SOUP_STATUS_OK)
     {
       g_set_error (&error,
@@ -309,6 +316,12 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
       goto out;
     }
 
+  /* This autodiscover attempt was successful. Save the result now so
+   * that it won't get lost when we hear from another autodiscover
+   * attempt for the same GAsyncResult.
+   */
+  g_simple_async_result_set_op_res_gboolean (data->res, op_res);
+
   for (idx = 0; idx < size; idx++)
     {
       if (data->msgs[idx] != NULL)
@@ -342,7 +355,12 @@ ews_client_autodiscover_response_cb (SoupSession *session, SoupMessage *msg, gpo
       GMainContext *context;
       GSource *source;
 
-      g_simple_async_result_set_op_res_gboolean (data->res, op_res);
+      /* The result of the GAsyncResult should already be set when we
+       * get here. If it wasn't explicitly set to TRUE then
+       * autodiscovery has failed and the default value of the
+       * GAsyncResult (which is FALSE) should be returned to the
+       * original caller.
+       */
 
       source = g_idle_source_new ();
       g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);


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