dovecot-1.2: dict quota: Don't crash when recalculating quota (a...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 16 14:50:24 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/dcc80beecb40
changeset: 8276:dcc80beecb40
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 16 14:49:37 2008 +0300
description:
dict quota: Don't crash when recalculating quota (and quota warnings enabled).

diffstat:

1 file changed, 8 insertions(+), 8 deletions(-)
src/plugins/quota/quota-storage.c |   16 ++++++++--------

diffs (35 lines):

diff -r 0a8320a714b5 -r dcc80beecb40 src/plugins/quota/quota-storage.c
--- a/src/plugins/quota/quota-storage.c	Thu Oct 16 12:47:05 2008 +0300
+++ b/src/plugins/quota/quota-storage.c	Thu Oct 16 14:49:37 2008 +0300
@@ -283,11 +283,8 @@ static void quota_mailbox_sync_notify(st
 	if (qbox->module_ctx.super.sync_notify != NULL)
 		qbox->module_ctx.super.sync_notify(box, uid, sync_type);
 
-	if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE || qbox->recalculate) {
-		if (uid == 0)
-			quota_mailbox_sync_finish(qbox);
+	if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE || qbox->recalculate)
 		return;
-	}
 
 	/* we're in the middle of syncing the mailbox, so it's a bad idea to
 	   try and get the message sizes at this point. Rely on sizes that
@@ -335,11 +332,14 @@ static int quota_mailbox_sync_deinit(str
 				     struct mailbox_status *status_r)
 {
 	struct quota_mailbox *qbox = QUOTA_CONTEXT(ctx->box);
-
-	/* just in case sync_notify() wasn't called with uid=0 */
+	int ret;
+
+	ret = qbox->module_ctx.super.sync_deinit(ctx, status_items, status_r);
+	/* update quota only after syncing is finished. the quota commit may
+	   recalculate the quota and cause all mailboxes to be synced,
+	   including the one we're already syncing. */
 	quota_mailbox_sync_finish(qbox);
-
-	return qbox->module_ctx.super.sync_deinit(ctx, status_items, status_r);
+	return ret;
 }
 
 static int quota_mailbox_close(struct mailbox *box)


More information about the dovecot-cvs mailing list