Skip to content

Commit

Permalink
don't needlessly call cyrusdb_abort()/cyrusdb_commit()
Browse files Browse the repository at this point in the history
Signed-off-by: Felix J. Ogris <[email protected]>
  • Loading branch information
Felix J. Ogris authored and elliefm committed May 2, 2021
1 parent eea99d7 commit 8ac8520
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions imap/mboxlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3305,6 +3305,7 @@ EXPORTED int mboxlist_set_racls(int enabled)
{
struct txn *tid = NULL;
int r = 0;
int modified_mbdb = 0;

init_internal();

Expand All @@ -3313,6 +3314,7 @@ EXPORTED int mboxlist_set_racls(int enabled)
/* remove */
r = cyrusdb_foreach(mbdb, "$RACL", 5, NULL, del_cb, &tid, &tid);
if (!r) have_racl = 0;
modified_mbdb = 1;
}
if (enabled && !have_racl) {
/* add */
Expand All @@ -3325,12 +3327,15 @@ EXPORTED int mboxlist_set_racls(int enabled)
if (r) {
syslog(LOG_ERR, "ERROR: failed to add reverse acl support %s", error_message(r));
}
modified_mbdb = 1;
mboxlist_entry_free(&mbrock.mbentry);
if (!r) r = cyrusdb_store(mbdb, "$RACL", 5, vbuf.s, vbuf.len, &tid);
if (!r) have_racl = RACL_VERSION;
buf_free(&vbuf);
}

if (!modified_mbdb || !tid) return r;

if (r)
cyrusdb_abort(mbdb, tid);
else
Expand All @@ -3349,6 +3354,7 @@ EXPORTED int mboxlist_set_runiqueid(int enabled)
{
struct txn *tid = NULL;
int r = 0;
int modified_mbdb = 0;

init_internal();

Expand All @@ -3357,6 +3363,7 @@ EXPORTED int mboxlist_set_runiqueid(int enabled)
/* remove */
r = cyrusdb_foreach(mbdb, "$RUNQ", 5, NULL, del_cb, &tid, &tid);
if (!r) have_runq = 0;
modified_mbdb = 1;
}
if (enabled && !have_runq) {
/* add */
Expand All @@ -3369,12 +3376,15 @@ EXPORTED int mboxlist_set_runiqueid(int enabled)
if (r) {
syslog(LOG_ERR, "ERROR: failed to add reverse uniqueid support %s", error_message(r));
}
modified_mbdb = 1;
mboxlist_entry_free(&mbrock.mbentry);
if (!r) r = cyrusdb_store(mbdb, "$RUNQ", 5, vbuf.s, vbuf.len, &tid);
if (!r) have_runq = RUNQ_VERSION;
buf_free(&vbuf);
}

if (!modified_mbdb || !tid) return r;

if (r)
cyrusdb_abort(mbdb, tid);
else
Expand Down

0 comments on commit 8ac8520

Please sign in to comment.