From: Timo Sirainen Date: Wed, 19 Jul 2017 13:53:17 +0000 (+0300) Subject: *-login: Cache director_username_hash between KICK-DIRECTOR-HASH commands X-Git-Tag: 2.2.33.rc1~98 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=380127c453f30e52fb1402ac0363a328edc14227;p=thirdparty%2Fdovecot%2Fcore.git *-login: Cache director_username_hash between KICK-DIRECTOR-HASH commands This should make the kicking much faster, which is important when director is moving thousands of users. --- diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index 09e1c37d9c..19d142d3a4 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -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; diff --git a/src/login-common/login-proxy.c b/src/login-common/login-proxy.c index 80b28c8975..e48a472a2e 100644 --- a/src/login-common/login-proxy.c +++ b/src/login-common/login-proxy.c @@ -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