From: Timo Sirainen Date: Thu, 1 Oct 2015 09:49:25 +0000 (+0300) Subject: push-notification: Cache the metadata lookup in OX driver. X-Git-Tag: 2.2.19~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfebce6840b843e8ae76f632537db4cfd29041fc;p=thirdparty%2Fdovecot%2Fcore.git push-notification: Cache the metadata lookup in OX driver. --- diff --git a/src/plugins/push-notification/push-notification-driver-ox.c b/src/plugins/push-notification/push-notification-driver-ox.c index b4c30815fe..73ff78db26 100644 --- a/src/plugins/push-notification/push-notification-driver-ox.c +++ b/src/plugins/push-notification/push-notification-driver-ox.c @@ -37,6 +37,7 @@ static struct push_notification_driver_ox_global *ox_global = NULL; /* This is data specific to an OX driver. */ struct push_notification_driver_ox_config { struct http_url *http_url; + const char *cached_ox_metadata; }; /* This is data specific to an OX driver transaction. */ @@ -97,6 +98,7 @@ push_notification_driver_ox_init(struct push_notification_driver_config *config, static const char *push_notification_driver_ox_get_metadata (struct push_notification_driver_txn *dtxn) { + struct push_notification_driver_ox_config *dconfig = dtxn->duser->context; struct mail_attribute_value attr; struct mailbox *inbox; struct mailbox_transaction_context *mctx = NULL; @@ -104,6 +106,9 @@ static const char *push_notification_driver_ox_get_metadata bool success = FALSE, use_existing_txn = FALSE; int ret; + if (dconfig->cached_ox_metadata != NULL) + return dconfig->cached_ox_metadata; + /* Get canonical INBOX, where private server-level metadata is stored. * See imap/cmd-getmetadata.c */ if ((dtxn->ptxn->t != NULL) && dtxn->ptxn->mbox->inbox_user) { @@ -146,6 +151,8 @@ static const char *push_notification_driver_ox_get_metadata mailbox_free(&inbox); } + dconfig->cached_ox_metadata = + p_strdup(dtxn->ptxn->puser->driverlist->pool, attr.value); return (success == TRUE) ? attr.value : NULL; }