dovecot-2.0-sslstream: *-login: Show better state with verbose_p...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Feb 13 02:55:44 EET 2010
details: http://hg.dovecot.org/dovecot-2.0-sslstream/rev/3e7e08af2991
changeset: 10199:3e7e08af2991
user: Timo Sirainen <tss at iki.fi>
date: Mon Oct 26 22:10:42 2009 -0400
description:
*-login: Show better state with verbose_proctitle=yes.
diffstat:
3 files changed, 32 insertions(+), 24 deletions(-)
src/login-common/client-common.c | 33 +++++++++------------------------
src/login-common/common.h | 1 +
src/login-common/main.c | 22 ++++++++++++++++++++++
diffs (137 lines):
diff -r 46d08ae1314f -r 3e7e08af2991 src/login-common/client-common.c
--- 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 @@ client_create(int fd, bool ssl, pool_t p
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_create(int fd, bool ssl, pool_t p
client->v.send_greeting(client);
else
client_set_auth_waiting(client);
+
+ login_refresh_proctitle();
return client;
}
@@ -100,12 +100,8 @@ void client_destroy(struct client *clien
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 @@ void client_destroy(struct client *clien
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 @@ bool client_unref(struct client **_clien
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 @@ static void client_start_tls(struct clie
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);
@@ -332,22 +333,6 @@ unsigned int clients_get_count(void)
unsigned int clients_get_count(void)
{
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 *
diff -r 46d08ae1314f -r 3e7e08af2991 src/login-common/common.h
--- 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 *glob
extern const struct login_settings *global_login_settings;
extern void **global_other_settings;
+void login_refresh_proctitle(void);
void login_process_preinit(void);
#endif
diff -r 46d08ae1314f -r 3e7e08af2991 src/login-common/main.c
--- 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"
@@ -26,6 +27,27 @@ void **global_other_settings;
void **global_other_settings;
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)
{
More information about the dovecot-cvs
mailing list