[evolution-data-server/gnome-3-26] [IMAPx] Wait for IDLE stop up to 10 seconds, then give up



commit 709483c6fc261df374f7e3b8e25379af3184c327
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 20 17:50:49 2017 +0200

    [IMAPx] Wait for IDLE stop up to 10 seconds, then give up
    
    Wait for IDLE stop had been related to time out set on the connection,
    which could be very long (as set by IDLE call itself). The server
    could be also unreachable due to network change, but this might
    not be always caught by the output stream. Having up to 10 seconds
    wait will make sure the IDLE stop request will not wait for too long.

 src/camel/providers/imapx/camel-imapx-server.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-server.c b/src/camel/providers/imapx/camel-imapx-server.c
index d75c4e7..a7ae865 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -6453,6 +6453,7 @@ camel_imapx_server_stop_idle_sync (CamelIMAPXServer *is,
 {
        GCancellable *idle_cancellable;
        gulong handler_id = 0;
+       gint64 wait_end_time;
        gboolean success = TRUE;
 
        g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
@@ -6525,9 +6526,12 @@ camel_imapx_server_stop_idle_sync (CamelIMAPXServer *is,
                g_mutex_lock (&is->priv->idle_lock);
        }
 
+       /* Give server 10 seconds to process the DONE command, if it fails, then give up and reconnect */
+       wait_end_time = g_get_monotonic_time () + 10 * G_TIME_SPAN_SECOND;
+
        while (success && is->priv->idle_state != IMAPX_IDLE_STATE_OFF &&
               !g_cancellable_is_cancelled (cancellable)) {
-               g_cond_wait (&is->priv->idle_cond, &is->priv->idle_lock);
+               success = g_cond_wait_until (&is->priv->idle_cond, &is->priv->idle_lock, wait_end_time);
        }
 
        g_mutex_unlock (&is->priv->idle_lock);


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