]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification: Cache the metadata lookup in OX driver.
authorTimo Sirainen <tss@iki.fi>
Thu, 1 Oct 2015 09:49:25 +0000 (12:49 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 1 Oct 2015 09:49:25 +0000 (12:49 +0300)
src/plugins/push-notification/push-notification-driver-ox.c

index b4c30815feb29c72ae3db0bdcf3ebbad87bf310e..73ff78db26c951e6e526968c5bc2546a58ddb1ba 100644 (file)
@@ -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;
 }