[evolution-data-server] Do not hold lock while waiting for parser thread to quit - imapx



commit fea872ec8105ceeb55574eb98ea90af131fb3457
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Wed Feb 24 14:52:55 2010 +0530

    Do not hold lock while waiting for parser thread to quit - imapx

 camel/providers/imapx/camel-imapx-server.c |   17 +++++++++++------
 camel/providers/imapx/camel-imapx-server.h |    2 ++
 2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 3eab8e1..f1bf0f1 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2662,7 +2662,7 @@ imapx_job_refresh_info_done(CamelIMAPXServer *is, CamelIMAPXCommand *ic)
 		for (i=0; i<infos->len; i++) {
 			struct _refresh_info *r = &g_array_index(infos, struct _refresh_info, i);
 
-			while (s_minfo && uid_cmp(camel_message_info_uid(s_minfo), r->uid, s) != 0) {
+			while (s_minfo && uid_cmp(camel_message_info_uid(s_minfo), r->uid, s) < 0) {
 				const gchar *uid = camel_message_info_uid (s_minfo);
 
 				camel_folder_change_info_remove_uid (job->u.refresh_info.changes, uid);
@@ -3408,7 +3408,6 @@ camel_imapx_server_new(CamelStore *store, CamelURL *url)
 	return is;
 }
 
-/* Called with a connect lock */
 static gboolean
 imapx_disconnect (CamelIMAPXServer *is)
 {
@@ -3417,6 +3416,9 @@ imapx_disconnect (CamelIMAPXServer *is)
 	CAMEL_SERVICE_REC_LOCK (is->store, connect_lock);
 	g_static_rec_mutex_lock (&is->ostream_lock);
 
+	if (is->state == IMAPX_DISCONNECTED)
+		goto exit;
+
 	if (is->stream) {
 		if (camel_stream_close (is->stream->source) == -1)
 			ret = FALSE;
@@ -3425,8 +3427,6 @@ imapx_disconnect (CamelIMAPXServer *is)
 		is->stream = NULL;
 	}
 
-	is->state = IMAPX_DISCONNECTED;
-
 	if (is->select_folder) {
 		camel_object_unref(is->select_folder);
 		is->select_folder = NULL;
@@ -3446,7 +3446,10 @@ imapx_disconnect (CamelIMAPXServer *is)
 		camel_imapx_command_free (is->literal);
 		is->literal = NULL;
 	}
-				
+	
+	is->state = IMAPX_DISCONNECTED;
+
+exit:	
 	g_static_rec_mutex_unlock (&is->ostream_lock);
 	CAMEL_SERVICE_REC_UNLOCK (is->store, connect_lock);
 
@@ -3486,8 +3489,10 @@ camel_imapx_server_connect(CamelIMAPXServer *is, gint state)
 		if (imapx_idle_supported (is))
 			imapx_exit_idle (is);
 
+		CAMEL_SERVICE_REC_UNLOCK (is->store, connect_lock);
+
 		pthread_join (is->parser_thread_id, NULL);
-		ret = TRUE;
+		return TRUE;
 	}
 
 exit:
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index 585018c..5d98ef1 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -89,6 +89,8 @@ struct _CamelIMAPXServer {
 	   processed after the command completes. */
 	GSList *expunged;
 
+	/* connect_lock used for locking input stream locking and 
+	   ostream_lock for locking output stream */
 	pthread_t parser_thread_id;
 	GStaticRecMutex ostream_lock;
 



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