]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Cache director_username_hash between KICK-DIRECTOR-HASH commands
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 19 Jul 2017 13:53:17 +0000 (16:53 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 12 Sep 2017 10:56:49 +0000 (13:56 +0300)
This should make the kicking much faster, which is important when director
is moving thousands of users.

src/login-common/client-common.h
src/login-common/login-proxy.c

index 09e1c37d9cbbf527a9e2ca3c882dabcfd2826d65..19d142d3a4252a11aa171cbe0264d64fed306249 100644 (file)
@@ -173,6 +173,9 @@ struct client {
           as in global_alt_usernames. If some field doesn't exist, it's "".
           Can also be NULL if there are no user_* fields. */
        const char **alt_usernames;
+       /* director_username_hash cached, if non-zero */
+       unsigned int director_username_hash_cache;
+
        unsigned int destroyed:1;
        unsigned int input_blocked:1;
        unsigned int login_success:1;
index 80b28c8975cedbbf626d6caf30a027bd15238fa0..e48a472a2e99933deffe173a48edffbfc77ebf3d 100644 (file)
@@ -930,8 +930,14 @@ login_proxy_cmd_kick_alt(struct ipc_cmd *cmd, const char *const *args)
 
 static unsigned int director_username_hash(struct client *client)
 {
-       return mail_user_hash(client->virtual_user,
-                             client->set->director_username_hash);
+       if (client->director_username_hash_cache != 0) {
+               /* already set */
+       } else {
+               client->director_username_hash_cache =
+                       mail_user_hash(client->virtual_user,
+                                      client->set->director_username_hash);
+       }
+       return client->director_username_hash_cache;
 }
 
 static void