Mercurial > dovecot > core-2.2
changeset 19262:fe5890ba0618
push-notification: Fix infinite recursive loop in OX driver
author | Michael Slusarz <michael.slusarz@dovecot.fi> |
---|---|
date | Wed, 30 Sep 2015 17:49:24 -0600 |
parents | 160eae376b44 |
children | 6f86db8428e6 |
files | src/plugins/push-notification/push-notification-driver-ox.c |
diffstat | 1 files changed, 18 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/push-notification/push-notification-driver-ox.c Wed Sep 30 17:45:49 2015 -0600 +++ b/src/plugins/push-notification/push-notification-driver-ox.c Wed Sep 30 17:49:24 2015 -0600 @@ -101,18 +101,25 @@ struct mailbox *inbox; struct mailbox_transaction_context *mctx = NULL; struct mail_namespace *ns; - bool success = FALSE; + bool success = FALSE, use_existing_txn = FALSE; int ret; /* Get canonical INBOX, where private server-level metadata is stored. * See imap/cmd-getmetadata.c */ - ns = mail_namespace_find_inbox(dtxn->ptxn->muser->namespaces); - inbox = mailbox_alloc(ns->list, "INBOX", MAILBOX_FLAG_READONLY); - if (mailbox_open(inbox) < 0) { - i_error(OX_LOG_LABEL "Skipped because unable to open INBOX: %s", - mailbox_get_last_error(inbox, NULL)); + if ((dtxn->ptxn->t != NULL) && dtxn->ptxn->mbox->inbox_user) { + /* Use the currently open transaction. */ + inbox = dtxn->ptxn->mbox; + mctx = dtxn->ptxn->t; + use_existing_txn = TRUE; } else { - mctx = mailbox_transaction_begin(inbox, 0); + ns = mail_namespace_find_inbox(dtxn->ptxn->muser->namespaces); + inbox = mailbox_alloc(ns->list, "INBOX", MAILBOX_FLAG_READONLY); + if (mailbox_open(inbox) < 0) { + i_error(OX_LOG_LABEL "Skipped because unable to open INBOX: %s", + mailbox_get_last_error(inbox, NULL)); + } else { + mctx = mailbox_transaction_begin(inbox, 0); + } } if (mctx != NULL) { @@ -128,14 +135,16 @@ success = TRUE; } - if (mailbox_transaction_commit(&mctx) < 0) { + if (!use_existing_txn && (mailbox_transaction_commit(&mctx) < 0)) { i_error(OX_LOG_LABEL "Transaction commit failed: %s", mailbox_get_last_error(inbox, NULL)); /* the commit doesn't matter though. */ } } - mailbox_free(&inbox); + if (!use_existing_txn) { + mailbox_free(&inbox); + } return (success == TRUE) ? attr.value : NULL; }