Mercurial > dovecot > core-2.2
changeset 21925:eb3ae53f8ac0
*-login: Move code to login_anvil_init()
Calling this allows plugins that need to talk to anvil make sure they have
an anvil connection even if mail_max_userip_connections=0.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 05 Apr 2017 12:36:32 +0300 |
parents | 2f1a7c1007d7 |
children | 265a9cc53218 |
files | src/login-common/login-common.h src/login-common/main.c |
diffstat | 2 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/login-common.h Wed Apr 05 12:52:14 2017 +0300 +++ b/src/login-common/login-common.h Wed Apr 05 12:36:32 2017 +0300 @@ -64,6 +64,9 @@ void login_refresh_proctitle(void); void login_client_destroyed(void); +/* Call to guarantee that the "anvil" global variable is initialized. */ +void login_anvil_init(void); + int login_binary_run(const struct login_binary *binary, int argc, char *argv[]);
--- a/src/login-common/main.c Wed Apr 05 12:52:14 2017 +0300 +++ b/src/login-common/main.c Wed Apr 05 12:36:32 2017 +0300 @@ -273,6 +273,16 @@ return FALSE; } +void login_anvil_init(void) +{ + if (anvil != NULL) + return; + + anvil = anvil_client_init("anvil", anvil_reconnect_callback, 0); + if (anvil_client_connect(anvil, TRUE) < 0) + i_fatal("Couldn't connect to anvil"); +} + static const struct ip_addr * parse_login_source_ips(const char *ips_str, unsigned int *count_r) { @@ -360,11 +370,8 @@ i_assert(strcmp(global_ssl_settings->ssl, "no") == 0 || ssl_initialized); - if (global_login_settings->mail_max_userip_connections > 0) { - anvil = anvil_client_init("anvil", anvil_reconnect_callback, 0); - if (anvil_client_connect(anvil, TRUE) < 0) - i_fatal("Couldn't connect to anvil"); - } + if (global_login_settings->mail_max_userip_connections > 0) + login_anvil_init(); /* read the login_source_ips before chrooting so it can access /etc/hosts */