dovecot-2.1: auth: Show a better auth worker process title.

dovecot at dovecot.org dovecot at dovecot.org
Thu Jan 19 16:33:24 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/1fa75cada826
changeset: 13957:1fa75cada826
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jan 19 16:33:13 2012 +0200
description:
auth: Show a better auth worker process title.

diffstat:

 src/auth/auth-common.h        |   1 +
 src/auth/auth-worker-client.c |   8 ++++++++
 src/auth/auth-worker-client.h |   2 ++
 src/auth/main.c               |  20 +++++++++++++-------
 4 files changed, 24 insertions(+), 7 deletions(-)

diffs (121 lines):

diff -r 05940646a0f4 -r 1fa75cada826 src/auth/auth-common.h
--- a/src/auth/auth-common.h	Thu Jan 19 16:17:52 2012 +0200
+++ b/src/auth/auth-common.h	Thu Jan 19 16:33:13 2012 +0200
@@ -9,6 +9,7 @@
 extern struct auth_penalty *auth_penalty;
 
 void auth_refresh_proctitle(void);
+void auth_worker_refresh_proctitle(const char *state);
 void auth_module_load(const char *names);
 
 #endif
diff -r 05940646a0f4 -r 1fa75cada826 src/auth/auth-worker-client.c
--- a/src/auth/auth-worker-client.c	Thu Jan 19 16:17:52 2012 +0200
+++ b/src/auth/auth-worker-client.c	Thu Jan 19 16:33:13 2012 +0200
@@ -16,6 +16,9 @@
 
 #define OUTBUF_THROTTLE_SIZE (1024*10)
 
+#define CLIENT_STATE_HANDSHAKE "handshaking"
+#define CLIENT_STATE_IDLE "idling"
+
 struct auth_worker_client {
 	int refcount;
 
@@ -534,6 +537,7 @@
 		return FALSE;
 	}
 
+	auth_worker_refresh_proctitle(args[1]);
 	if (strcmp(args[1], "PASSV") == 0)
 		ret = auth_worker_handle_passv(client, id, args + 2);
 	else if (strcmp(args[1], "PASSL") == 0)
@@ -548,6 +552,7 @@
 		i_error("BUG: Auth-worker received unknown command: %s",
 			args[1]);
 	}
+	auth_worker_refresh_proctitle(CLIENT_STATE_IDLE);
         return ret;
 }
 
@@ -616,6 +621,7 @@
 			return;
 		}
 		client->dbhash_received = TRUE;
+		auth_worker_refresh_proctitle(CLIENT_STATE_IDLE);
 	}
 
         client->refcount++;
@@ -664,6 +670,7 @@
 	client->output = o_stream_create_fd(fd, (size_t)-1, FALSE);
 	o_stream_set_flush_callback(client->output, auth_worker_output, client);
 	client->io = io_add(fd, IO_READ, auth_worker_input, client);
+	auth_worker_refresh_proctitle(CLIENT_STATE_HANDSHAKE);
 
 	auth_worker_client = client;
 	return client;
@@ -687,6 +694,7 @@
 	client->fd = -1;
 	auth_worker_client_unref(&client);
 
+	auth_worker_refresh_proctitle(NULL);
 	auth_worker_client = NULL;
 	master_service_client_connection_destroyed(master_service);
 }
diff -r 05940646a0f4 -r 1fa75cada826 src/auth/auth-worker-client.h
--- a/src/auth/auth-worker-client.h	Thu Jan 19 16:17:52 2012 +0200
+++ b/src/auth/auth-worker-client.h	Thu Jan 19 16:33:13 2012 +0200
@@ -11,4 +11,6 @@
 void auth_worker_client_destroy(struct auth_worker_client **client);
 void auth_worker_client_unref(struct auth_worker_client **client);
 
+const char *auth_worker_client_get_state(struct auth_worker_client *client);
+
 #endif
diff -r 05940646a0f4 -r 1fa75cada826 src/auth/main.c
--- a/src/auth/main.c	Thu Jan 19 16:17:52 2012 +0200
+++ b/src/auth/main.c	Thu Jan 19 16:33:13 2012 +0200
@@ -59,16 +59,11 @@
 
 void auth_refresh_proctitle(void)
 {
-	const char *auth_worker_prefix;
-
-	if (!global_auth_settings->verbose_proctitle)
+	if (!global_auth_settings->verbose_proctitle || worker)
 		return;
 
-	auth_worker_prefix = worker ? "worker " : "";
-
 	process_title_set(t_strdup_printf(
-		"%s[%u wait, %u passdb, %u userdb]",
-		auth_worker_prefix,
+		"[%u wait, %u passdb, %u userdb]",
 		auth_request_state_count[AUTH_REQUEST_STATE_NEW] +
 		auth_request_state_count[AUTH_REQUEST_STATE_MECH_CONTINUE] +
 		auth_request_state_count[AUTH_REQUEST_STATE_FINISHED],
@@ -76,6 +71,16 @@
 		auth_request_state_count[AUTH_REQUEST_STATE_USERDB]));
 }
 
+void auth_worker_refresh_proctitle(const char *state)
+{
+	if (!global_auth_settings->verbose_proctitle || !worker)
+		return;
+
+	if (state == NULL)
+		state = "waiting for connection";
+	process_title_set(t_strdup_printf("worker: %s", state));
+}
+
 static const char *const *read_global_settings(void)
 {
 	struct master_service_settings_output set_output;
@@ -244,6 +249,7 @@
 		passdb_cache_init(global_auth_settings);
 	}
 	auth_refresh_proctitle();
+	auth_worker_refresh_proctitle(NULL);
 }
 
 static void main_deinit(void)


More information about the dovecot-cvs mailing list