[evolution-data-server] Fix locking issues in cancel_all_jobs()
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Fix locking issues in cancel_all_jobs()
- Date: Thu, 17 Jun 2010 09:51:47 +0000 (UTC)
commit ce175496b274877add810b2fef5dea7a990fce80
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 457d492..9d85fed 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -3880,34 +3880,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]