changeset 22655:c98a2d05c702

director: Show in process title how many users are being kicked.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:27:36 +0200
parents abe554f10805
children 1789bf2a1e01
files src/director/director.c src/director/director.h src/director/main.c
diffstat 3 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director.c	Sun Nov 05 23:01:56 2017 +0200
+++ b/src/director/director.c	Sun Nov 05 23:27:36 2017 +0200
@@ -984,6 +984,9 @@
 		break;
 	}
 
+	i_assert(ctx->dir->users_kicking_count > 0);
+	ctx->dir->users_kicking_count--;
+
 	ctx->callback_pending = FALSE;
 
 	user = user_directory_lookup(ctx->tag->users, ctx->username_hash);
@@ -1062,6 +1065,7 @@
 		cmd = t_strdup_printf("proxy\t*\tKICK-DIRECTOR-HASH\t%u",
 				      user->username_hash);
 		ctx->callback_pending = TRUE;
+		dir->users_kicking_count++;
 		ipc_client_cmd(dir->ipc_proxy, cmd,
 			       director_kill_user_callback, ctx);
 	} else {
@@ -1143,13 +1147,18 @@
 
 static void
 director_kick_user_callback(enum ipc_client_cmd_state state,
-			    const char *data, void *context ATTR_UNUSED)
+			    const char *data, void *context)
 {
+	struct director *dir = context;
+
 	if (state == IPC_CLIENT_CMD_STATE_REPLY) {
 		/* shouldn't get here. the command reply isn't finished yet. */
 		i_error("login process sent unexpected reply to kick: %s", data);
+		return;
 	}
 
+	i_assert(dir->users_kicking_count > 0);
+	dir->users_kicking_count--;
 }
 
 void director_kick_user(struct director *dir, struct director_host *src,
@@ -1159,8 +1168,9 @@
 
 	str_append(cmd, "proxy\t*\tKICK\t");
 	str_append_tabescaped(cmd, username);
+	dir->users_kicking_count++;
 	ipc_client_cmd(dir->ipc_proxy, str_c(cmd),
-		       director_kick_user_callback, (void *)NULL);
+		       director_kick_user_callback, dir);
 
 	if (orig_src == NULL) {
 		orig_src = dir->self_host;
@@ -1184,8 +1194,9 @@
 	str_append_tabescaped(cmd, field);
 	str_append_c(cmd, '\t');
 	str_append_tabescaped(cmd, value);
+	dir->users_kicking_count++;
 	ipc_client_cmd(dir->ipc_proxy, str_c(cmd),
-		       director_kick_user_callback, (void *)NULL);
+		       director_kick_user_callback, dir);
 
 	if (orig_src == NULL) {
 		orig_src = dir->self_host;
@@ -1210,8 +1221,9 @@
 
 	cmd = t_strdup_printf("proxy\t*\tKICK-DIRECTOR-HASH\t%u\t%s",
 			      username_hash, net_ip2addr(except_ip));
+	dir->users_kicking_count++;
 	ipc_client_cmd(dir->ipc_proxy, cmd,
-		       director_kick_user_callback, (void *)NULL);
+		       director_kick_user_callback, dir);
 
 	if (orig_src == NULL) {
 		orig_src = dir->self_host;
--- a/src/director/director.h	Sun Nov 05 23:01:56 2017 +0200
+++ b/src/director/director.h	Sun Nov 05 23:27:36 2017 +0200
@@ -121,6 +121,8 @@
 	struct mail_host_list *orig_config_hosts;
 	/* Number of users currently being moved */
 	unsigned int users_moving_count;
+	/* Number of users currently being kicked */
+	unsigned int users_kicking_count;
 	/* Number of requests currently delayed */
 	unsigned int requests_delayed_count;
 
--- a/src/director/main.c	Sun Nov 05 23:01:56 2017 +0200
+++ b/src/director/main.c	Sun Nov 05 23:27:36 2017 +0200
@@ -61,6 +61,8 @@
 		str_printfa(str, ", %u delayed", director->requests_delayed_count);
 	if (director->users_moving_count > 0)
 		str_printfa(str, ", %u moving", director->users_moving_count);
+	if (director->users_kicking_count > 0)
+		str_printfa(str, ", %u kicking", director->users_kicking_count);
 	str_printfa(str, ", %lu req/s",
 		    (unsigned long)(director->num_requests - prev_requests));
 	str_printfa(str, ", %llu+%llu kB/s",