Mercurial > dovecot > core-2.2
changeset 22478:c647979828d1
*-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.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 19 Jul 2017 16:53:17 +0300 |
parents | 125e78e85bcc |
children | 90957875c55b |
files | src/login-common/client-common.h src/login-common/login-proxy.c |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/client-common.h Wed Jul 19 16:49:18 2017 +0300 +++ b/src/login-common/client-common.h Wed Jul 19 16:53:17 2017 +0300 @@ -173,6 +173,9 @@ 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;
--- a/src/login-common/login-proxy.c Wed Jul 19 16:49:18 2017 +0300 +++ b/src/login-common/login-proxy.c Wed Jul 19 16:53:17 2017 +0300 @@ -930,8 +930,14 @@ 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