[evolution-data-server] Fix a crash while disconnecting moving from online to offline



commit 2da2db87a346d8b00cb94aa8b75690e34feeb7f2
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Wed Dec 30 07:28:50 2009 +0530

    Fix a crash while disconnecting moving from online to offline

 camel/providers/imapx/camel-imapx-server.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 4c43281..6602f4c 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2580,7 +2580,10 @@ imapx_parser_thread (gpointer d)
 		if (camel_exception_is_set (&ex)) {
 			if (errno == EINTR || !g_ascii_strcasecmp (ex.desc, "io error")) {
 				cancel_all_jobs (is, &ex);
+
+				g_mutex_lock (is->connect_lock);
 				imapx_disconnect (is);
+				g_mutex_unlock (is->connect_lock);
 			}
 
 			if (errno == EINTR)
@@ -2672,12 +2675,18 @@ camel_imapx_server_new(CamelStore *store, CamelURL *url)
 	return is;
 }
 
-
+/* Called with a connect lock */
 static gboolean
 imapx_disconnect (CamelIMAPXServer *is)
 {
+	gboolean ret = TRUE;
+	
+	if (!is->stream)
+		goto done;
+	
 	if (camel_stream_close (is->stream->source) == -1) {
-		return FALSE;
+		ret = FALSE;
+		goto done;
 	}
 			
 	camel_object_unref (CAMEL_OBJECT (is->stream));
@@ -2690,7 +2699,8 @@ imapx_disconnect (CamelIMAPXServer *is)
 	g_free(is->select);
 	is->select = NULL;
 	
-	return TRUE;
+done:
+	return ret;
 }
 
 /* Client commands */



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