[evolution-data-server/gnome-2-30] Fix locking issues in cancel_all_jobs()



commit ca21beb3adaec15eca871e09ebc6ee8467a77f78
Author: David Woodhouse <David Woodhouse intel com>
Date:   Thu Jun 17 00:14:24 2010 +0100

    Fix locking issues in cancel_all_jobs()
    
    While debugging bug 621740, the race conditions in here were suspected.
    On balance they probably weren't the cause, but fix them anyway for good
    measure.

 camel/providers/imapx/camel-imapx-server.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 014632f..5e983f4 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -3814,34 +3814,27 @@ imapx_job_sync_changes_start(CamelIMAPXServer *is, CamelIMAPXJob *job)
 static void
 cancel_all_jobs (CamelIMAPXServer *is, CamelException *ex)
 {
-	CamelIMAPXCommand *cw, *cn;
+	CamelIMAPXCommand **cw, *ic;
 	gint i = 0;
 
 	while (i < 2) {
 		QUEUE_LOCK(is);
 		if (i == 1)
-			cw = (CamelIMAPXCommand *) is->queue.head;
+			cw = (CamelIMAPXCommand **) &is->queue.head;
 		else
-			cw = (CamelIMAPXCommand *) is->active.head;
+			cw = (CamelIMAPXCommand **) &is->active.head;
 
-		cn = cw->next;
-		QUEUE_UNLOCK(is);
-
-		while (cn) {
-			QUEUE_LOCK(is);
-			camel_dlist_remove ((CamelDListNode *)cw);
+		while ((*cw)->next) {
+			ic = *cw;
+			camel_dlist_remove ((CamelDListNode *)ic);
 			QUEUE_UNLOCK(is);
 
-			camel_exception_set (cw->ex, ex->id, ex->desc);
-
-			cw->complete (is, cw);
-			cw = cn;
+			camel_exception_set (ic->ex, ex->id, ex->desc);
+			ic->complete (is, ic);
 
 			QUEUE_LOCK(is);
-			cn = cn->next;
-			QUEUE_UNLOCK(is);
 		}
-
+		QUEUE_UNLOCK(is);
 		i++;
 	}
 }



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