Skip to content

Commit

Permalink
quota: fix leaked quotadb transaction
Browse files Browse the repository at this point in the history
A transaction leaked in mboxlist_setquota if the mailbox didn't
exist.
  • Loading branch information
Bron Gondwana committed May 26, 2011
1 parent 0edda04 commit 63cb7d5
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions imap/mboxlist.c
Expand Up @@ -2439,15 +2439,13 @@ int mboxlist_setquota(const char *root, int newquota, int force)
q.limit = newquota;
r = quota_write(&q, &tid);
}
if (!r) quota_commit(&tid);
else quota_abort(&tid);
if (!r)
quota_commit(&tid);
goto done;
}

if (r != IMAP_QUOTAROOT_NONEXISTENT) {
if (tid) quota_abort(&tid);
if (r != IMAP_QUOTAROOT_NONEXISTENT)
goto done;
}

/*
* Have to create a new quota root
Expand Down Expand Up @@ -2489,21 +2487,21 @@ int mboxlist_setquota(const char *root, int newquota, int force)
q.used = 0;
q.limit = newquota;
r = quota_write(&q, &tid);
if (!r) quota_commit(&tid);
else quota_abort(&tid);
if (r) goto done;

quota_commit(&tid);

/* recurse through mailboxes, setting the quota and finding
* out the usage */
if (!r) {
/* top level mailbox */
if (have_mailbox)
mboxlist_changequota(root, 0, 0, (void *)root);
/* top level mailbox */
if (have_mailbox)
mboxlist_changequota(root, 0, 0, (void *)root);

/* submailboxes - we're using internal names here */
mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_changequota, (void *)root);
}
/* submailboxes - we're using internal names here */
mboxlist_findall(NULL, pattern, 1, 0, 0, mboxlist_changequota, (void *)root);

done:
if (tid) quota_abort(&tid);
if (!r) sync_log_quota(root);

return r;
Expand Down

0 comments on commit 63cb7d5

Please sign in to comment.