Mercurial > dovecot > core-2.2
changeset 10198:3e7e08af2991 HEAD
*-login: Show better state with verbose_proctitle=yes.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 26 Oct 2009 22:10:42 -0400 |
parents | 46d08ae1314f |
children | 9d13e9f78d52 |
files | src/login-common/client-common.c src/login-common/common.h src/login-common/main.c |
diffstat | 3 files changed, 32 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/client-common.c Mon Oct 26 21:53:13 2009 -0400 +++ b/src/login-common/client-common.c Mon Oct 26 22:10:42 2009 -0400 @@ -71,8 +71,6 @@ DLLIST_PREPEND(&clients, client); clients_count++; - client_set_title(client); - client->to_idle_disconnect = timeout_add(CLIENT_LOGIN_IDLE_TIMEOUT_MSECS, client_idle_disconnect_timeout, client); @@ -84,6 +82,8 @@ client->v.send_greeting(client); else client_set_auth_waiting(client); + + login_refresh_proctitle(); return client; } @@ -100,12 +100,8 @@ if (reason != NULL) client_log(client, reason); - i_assert(clients_count > 0); - clients_count--; - if (last_client == client) { - i_assert(client->prev != NULL || clients_count == 0); + if (last_client == client) last_client = client->prev; - } DLLIST_REMOVE(&clients, client); if (client->input != NULL) @@ -165,6 +161,7 @@ if (auth_client != NULL) auth_client_deinit(&auth_client); } + login_refresh_proctitle(); } void client_destroy_success(struct client *client, const char *reason) @@ -209,7 +206,11 @@ i_free(client->auth_mech_name); pool_unref(&client->pool); + i_assert(clients_count > 0); + clients_count--; + master_service_client_connection_destroyed(master_service); + login_refresh_proctitle(); return FALSE; } @@ -267,7 +268,7 @@ client->starttls = TRUE; client->tls = TRUE; client->secured = TRUE; - client_set_title(client); + login_refresh_proctitle(); client->fd = fd_ssl; client->io = io_add(client->fd, IO_READ, client_input, client); @@ -334,22 +335,6 @@ return clients_count; } -void client_set_title(struct client *client) -{ - const char *addr; - - if (!client->set->verbose_proctitle || - master_service_get_client_limit(master_service) > 1) - return; - - addr = net_ip2addr(&client->ip); - if (addr == NULL) - addr = "??"; - - process_title_set(t_strdup_printf(client->tls ? - "[%s TLS]" : "[%s]", addr)); -} - static const struct var_expand_table * get_var_expand_table(struct client *client) {
--- a/src/login-common/common.h Mon Oct 26 21:53:13 2009 -0400 +++ b/src/login-common/common.h Mon Oct 26 22:10:42 2009 -0400 @@ -23,6 +23,7 @@ extern const struct login_settings *global_login_settings; extern void **global_other_settings; +void login_refresh_proctitle(void); void login_process_preinit(void); #endif
--- a/src/login-common/main.c Mon Oct 26 21:53:13 2009 -0400 +++ b/src/login-common/main.c Mon Oct 26 22:10:42 2009 -0400 @@ -3,6 +3,7 @@ #include "common.h" #include "ioloop.h" #include "randgen.h" +#include "process-title.h" #include "restrict-access.h" #include "restrict-process-size.h" #include "master-auth.h" @@ -27,6 +28,27 @@ static bool ssl_connections = FALSE; +void login_refresh_proctitle(void) +{ + struct client *client = clients; + const char *addr; + + if (!global_login_settings->verbose_proctitle) + return; + + if (clients_get_count() == 0) { + process_title_set(""); + } else if (clients_get_count() > 1 || client == NULL) { + process_title_set(t_strdup_printf("[%u connections (%u TLS)]", + clients_get_count(), ssl_proxy_get_count())); + } else if ((addr = net_ip2addr(&client->ip)) != NULL) { + process_title_set(t_strdup_printf(client->tls ? + "[%s TLS]" : "[%s]", addr)); + } else { + process_title_set(client->tls ? "[TLS]" : ""); + } +} + static void login_die(void) { login_proxy_kill_idle();