dovecot-2.2: push-notification: Removed optimization to init dri...

dovecot at dovecot.org dovecot at dovecot.org
Fri Oct 2 09:12:13 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/cb7b0ad2836a
changeset: 19269:cb7b0ad2836a
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Oct 02 11:13:14 2015 +0300
description:
push-notification: Removed optimization to init drivers only once.
Different users may have different drivers. And the previous
metadata-caching change especially isn't working without this change.

diffstat:

 src/plugins/push-notification/push-notification-driver-ox.c |   2 +-
 src/plugins/push-notification/push-notification-drivers.h   |   1 -
 src/plugins/push-notification/push-notification-plugin.c    |  64 ++++++------
 3 files changed, 31 insertions(+), 36 deletions(-)

diffs (134 lines):

diff -r 5f883bc3f380 -r cb7b0ad2836a src/plugins/push-notification/push-notification-driver-ox.c
--- a/src/plugins/push-notification/push-notification-driver-ox.c	Thu Oct 01 13:48:24 2015 +0300
+++ b/src/plugins/push-notification/push-notification-driver-ox.c	Fri Oct 02 11:13:14 2015 +0300
@@ -155,7 +155,7 @@
     }
 
     dconfig->cached_ox_metadata =
-        p_strdup(dtxn->ptxn->puser->driverlist->pool, attr.value);
+        p_strdup(dtxn->ptxn->muser->pool, attr.value);
     return (success == TRUE) ? attr.value : NULL;
 }
 
diff -r 5f883bc3f380 -r cb7b0ad2836a src/plugins/push-notification/push-notification-drivers.h
--- a/src/plugins/push-notification/push-notification-drivers.h	Thu Oct 01 13:48:24 2015 +0300
+++ b/src/plugins/push-notification/push-notification-drivers.h	Fri Oct 02 11:13:14 2015 +0300
@@ -70,7 +70,6 @@
 
 struct push_notification_driver_list {
     ARRAY(struct push_notification_driver_user *) drivers;
-    pool_t pool;
 };
 
 struct push_notification_user {
diff -r 5f883bc3f380 -r cb7b0ad2836a src/plugins/push-notification/push-notification-plugin.c
--- a/src/plugins/push-notification/push-notification-plugin.c	Thu Oct 01 13:48:24 2015 +0300
+++ b/src/plugins/push-notification/push-notification-plugin.c	Fri Oct 02 11:13:14 2015 +0300
@@ -26,9 +26,6 @@
                                   &mail_user_module_register);
 
 
-static struct push_notification_driver_list *dlist = NULL;
-
-
 static void
 push_notification_transaction_init(struct push_notification_txn *ptxn)
 {
@@ -235,7 +232,7 @@
             break;
         }
 
-        if (push_notification_driver_init(user, env, dlist->pool, &duser) < 0) {
+        if (push_notification_driver_init(user, env, user->pool, &duser) < 0) {
             break;
         }
 
@@ -247,16 +244,13 @@
     }
 }
 
-static void push_notification_driver_list_init(struct mail_user *user)
+static struct push_notification_driver_list *
+push_notification_driver_list_init(struct mail_user *user)
 {
-    pool_t pool;
+    struct push_notification_driver_list *dlist;
 
-    pool = pool_alloconly_create("push notification plugin", 1024);
-
-    dlist = p_new(pool, struct push_notification_driver_list, 1);
-    dlist->pool = pool;
-
-    p_array_init(&dlist->drivers, pool, 4);
+    dlist = p_new(user->pool, struct push_notification_driver_list, 1);
+    p_array_init(&dlist->drivers, user->pool, 4);
 
     push_notification_config_init(PUSH_NOTIFICATION_CONFIG, user, dlist);
 
@@ -266,18 +260,37 @@
         push_notification_config_init(PUSH_NOTIFICATION_CONFIG_OLD, user,
                                       dlist);
     }
+    return dlist;
+}
+
+static void push_notification_user_deinit(struct mail_user *user)
+{
+    struct push_notification_user *puser = PUSH_NOTIFICATION_USER_CONTEXT(user);
+    struct push_notification_driver_list *dlist = puser->driverlist;
+    struct push_notification_driver_user **duser;
+
+    array_foreach_modifiable(&dlist->drivers, duser) {
+        if ((*duser)->driver->v.deinit != NULL) {
+            (*duser)->driver->v.deinit(*duser);
+        }
+
+        if ((*duser)->driver->v.cleanup != NULL) {
+            (*duser)->driver->v.cleanup();
+        }
+    }
+    puser->module_ctx.super.deinit(user);
 }
 
 static void push_notification_user_created(struct mail_user *user)
 {
+    struct mail_user_vfuncs *v = user->vlast;
     struct push_notification_user *puser;
 
-    if (dlist == NULL) {
-        push_notification_driver_list_init(user);
-    }
-
     puser = p_new(user->pool, struct push_notification_user, 1);
-    puser->driverlist = dlist;
+    puser->module_ctx.super = *v;
+    user->vlast = &puser->module_ctx.super;
+    v->deinit = push_notification_user_deinit;
+    puser->driverlist = push_notification_driver_list_init(user);
 
     MODULE_CONTEXT_SET(user, push_notification_user_module, puser);
 }
@@ -328,23 +341,6 @@
 
 void push_notification_plugin_deinit(void)
 {
-    struct push_notification_driver_user **duser;
-
-    if (dlist != NULL) {
-        array_foreach_modifiable(&dlist->drivers, duser) {
-            if ((*duser)->driver->v.deinit != NULL) {
-                (*duser)->driver->v.deinit(*duser);
-            }
-
-            if ((*duser)->driver->v.cleanup != NULL) {
-                (*duser)->driver->v.cleanup();
-            }
-        }
-
-        array_free(&dlist->drivers);
-        pool_unref(&dlist->pool);
-    }
-
     push_notification_driver_unregister(&push_notification_driver_dlog);
     push_notification_driver_unregister(&push_notification_driver_ox);
 


More information about the dovecot-cvs mailing list