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



commit 8cdf298a99bef24456411cf7b8a36523454c2884
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 e753789..8c1cdeb 100644
--- a/src/camel/providers/imapx/camel-imapx-server.c
+++ b/src/camel/providers/imapx/camel-imapx-server.c
@@ -6465,6 +6465,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);
@@ -6537,9 +6538,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]