[evolution-data-server] Bug #676541 - Unreliable IMAP provider



commit d910ce402262a2aada4b14823495f7d134fe660d
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 8 13:08:22 2012 +0200

    Bug #676541 - Unreliable IMAP provider

 camel/providers/imap/camel-imap-command.c |   21 +++++++++++++++------
 camel/providers/imap/camel-imap-store.c   |   10 +++++++++-
 2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/camel/providers/imap/camel-imap-command.c b/camel/providers/imap/camel-imap-command.c
index 0bd312d..29bfc23 100644
--- a/camel/providers/imap/camel-imap-command.c
+++ b/camel/providers/imap/camel-imap-command.c
@@ -254,8 +254,10 @@ imap_command_start (CamelImapStore *store,
 	g_free (content);
 
 	if (nwritten == -1) {
+		/* do not pass cancellable, the connection is gone or
+		   the cancellable cancelled, thus there will be no I/O */
 		camel_service_disconnect_sync (
-			CAMEL_SERVICE (store), FALSE, cancellable, NULL);
+			CAMEL_SERVICE (store), FALSE, NULL, NULL);
 		return FALSE;
 	}
 
@@ -308,8 +310,10 @@ camel_imap_command_continuation (CamelImapStore *store,
 
 	if (camel_stream_write (store->ostream, cmd, cmdlen, cancellable, error) == -1 ||
 	    camel_stream_write (store->ostream, "\r\n", 2, cancellable, error) == -1) {
+		/* do not pass cancellable, the connection is gone or
+		   the cancellable cancelled, thus there will be no I/O */
 		camel_service_disconnect_sync (
-			CAMEL_SERVICE (store), FALSE, cancellable, NULL);
+			CAMEL_SERVICE (store), FALSE, NULL, NULL);
 		g_static_rec_mutex_unlock (&store->command_and_response_lock);
 		return NULL;
 	}
@@ -375,9 +379,10 @@ camel_imap_command_response (CamelImapStore *store,
 			if (!err || !*err)
 				err = g_strerror (104);
 
-			/* Connection was lost, no more data to fetch */
+			/* do not pass cancellable, the connection is gone or
+			   the cancellable cancelled, thus there will be no I/O */
 			camel_service_disconnect_sync (
-				service, FALSE, cancellable, NULL);
+				service, FALSE, NULL, NULL);
 			g_set_error (
 				error, CAMEL_SERVICE_ERROR,
 				CAMEL_SERVICE_ERROR_UNAVAILABLE,
@@ -579,9 +584,11 @@ imap_read_untagged (CamelImapStore *store,
 				length - nread,
 				cancellable, error);
 			if (n == -1) {
+				/* do not pass cancellable, the connection is gone or
+				   the cancellable cancelled, thus there will be no I/O */
 				camel_service_disconnect_sync (
 					CAMEL_SERVICE (store),
-					FALSE, cancellable, NULL);
+					FALSE, NULL, NULL);
 				g_string_free (str, TRUE);
 				goto lose;
 			}
@@ -594,9 +601,11 @@ imap_read_untagged (CamelImapStore *store,
 				error, CAMEL_SERVICE_ERROR,
 				CAMEL_SERVICE_ERROR_UNAVAILABLE,
 				_("Server response ended too soon."));
+			/* do not pass cancellable, the connection is gone or
+			   the cancellable cancelled, thus there will be no I/O */
 			camel_service_disconnect_sync (
 				CAMEL_SERVICE (store),
-				FALSE, cancellable, NULL);
+				FALSE, NULL, NULL);
 			g_string_free (str, TRUE);
 			goto lose;
 		}
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 5f30730..c2a4c23 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -840,6 +840,9 @@ imap_store_connect_sync (CamelService *service,
 
 	if (!connect_to_server_wrapper (service, cancellable, error) ||
 	    !imap_auth_loop (service, cancellable, error)) {
+		/* reset cancellable, in case it is cancelled,
+		   thus the disconnect is run */
+		g_cancellable_reset (cancellable);
 		camel_service_disconnect_sync (
 			service, TRUE, cancellable, NULL);
 		return FALSE;
@@ -1014,6 +1017,9 @@ done:
 	camel_store_summary_save ((CamelStoreSummary *) store->summary);
 
 	if (local_error != NULL) {
+		/* reset cancellable, in case it is cancelled,
+		   thus the disconnect is run */
+		g_cancellable_reset (cancellable);
 		camel_service_disconnect_sync (
 			service, TRUE, cancellable, NULL);
 		g_propagate_error (error, local_error);
@@ -3257,8 +3263,10 @@ camel_imap_store_readline (CamelImapStore *store,
 			g_prefix_error (
 				error, _("Server unexpectedly disconnected: "));
 
+		/* do not pass cancellable, the connection is gone or
+		   the cancellable cancelled, thus there will be no I/O */
 		camel_service_disconnect_sync (
-			CAMEL_SERVICE (store), FALSE, cancellable, NULL);
+			CAMEL_SERVICE (store), FALSE, NULL, NULL);
 		g_byte_array_free (ba, TRUE);
 		return -1;
 	}



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