From: Timo Sirainen Date: Wed, 19 Jul 2017 20:19:12 +0000 (+0300) Subject: virtual: Optimize mailbox_notify_changes() when there's only a single backend mailbox X-Git-Tag: 2.2.32.rc1~61 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67e951d6a20e2600009cb74a2417603c4f7408e1;p=thirdparty%2Fdovecot%2Fcore.git virtual: Optimize mailbox_notify_changes() when there's only a single backend mailbox --- diff --git a/src/plugins/virtual/virtual-storage.c b/src/plugins/virtual/virtual-storage.c index a2df0e60ca..efa51293af 100644 --- a/src/plugins/virtual/virtual-storage.c +++ b/src/plugins/virtual/virtual-storage.c @@ -711,14 +711,22 @@ static void virtual_notify_changes(struct mailbox *box) } array_foreach_modifiable(&mbox->backend_boxes, bboxp) { - /* we are already waiting for notifications */ - if ((*bboxp)->notify != NULL) - continue; - /* wait for notifications */ - if (virtual_notify_start(*bboxp) == 0) - continue; - /* it did not work, so open the mailbox and use - alternative method */ + if (array_count(&mbox->backend_boxes) == 1 && + (*bboxp)->box->opened) { + /* There's only a single backend mailbox and its + indexes are already opened. Might as well use the + backend directly for notifications. */ + } else { + /* we are already waiting for notifications */ + if ((*bboxp)->notify != NULL) + continue; + /* wait for notifications */ + if (virtual_notify_start(*bboxp) == 0) + continue; + /* it did not work, so open the mailbox and use + alternative method */ + } + if (!(*bboxp)->box->opened && virtual_backend_box_open(mbox, *bboxp) < 0) { /* we can't report error in here, so do it later */