changeset 22510:3c4348ffe0d6

director: Fix flush to kick the user also when all backends are down The user's host can't change, because there are no other hosts. So add a new parameter to force the kick anyway.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Wed, 20 Sep 2017 01:47:38 +0300
parents a9e00067e9e3
children f0694e6eda8d
files src/director/director.c src/director/director.h src/director/doveadm-connection.c
diffstat 3 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/director/director.c	Thu Sep 14 12:50:29 2017 +0300
+++ b/src/director/director.c	Wed Sep 20 01:47:38 2017 +0300
@@ -986,7 +986,7 @@
 
 void director_kill_user(struct director *dir, struct director_host *src,
 			struct user *user, struct mail_tag *tag,
-			struct mail_host *old_host)
+			struct mail_host *old_host, bool forced_kick)
 {
 	struct director_kill_context *ctx;
 	const char *cmd;
@@ -1017,7 +1017,7 @@
 				   director_user_move_timeout, user);
 	ctx->kill_state = USER_KILL_STATE_KILLING;
 
-	if (old_host != NULL && old_host != user->host) {
+	if ((old_host != NULL && old_host != user->host) || forced_kick) {
 		cmd = t_strdup_printf("proxy\t*\tKICK-DIRECTOR-HASH\t%u",
 				      user->username_hash);
 		ctx->callback_pending = TRUE;
@@ -1097,7 +1097,7 @@
 		user->username_hash, net_ip2addr(&user->host->ip)));
 	/* kill the user only after sending the USER-MOVE, because the kill
 	   may finish instantly. */
-	director_kill_user(dir, src, user, host->tag, old_host);
+	director_kill_user(dir, src, user, host->tag, old_host, FALSE);
 }
 
 static void
--- a/src/director/director.h	Thu Sep 14 12:50:29 2017 +0300
+++ b/src/director/director.h	Wed Sep 20 01:47:38 2017 +0300
@@ -203,7 +203,7 @@
 			       struct user *user) ATTR_NULL(3);
 void director_kill_user(struct director *dir, struct director_host *src,
 			struct user *user, struct mail_tag *tag,
-			struct mail_host *old_host);
+			struct mail_host *old_host, bool forced_kick);
 void director_move_user(struct director *dir, struct director_host *src,
 			struct director_host *orig_src,
 			unsigned int username_hash, struct mail_host *host)
--- a/src/director/doveadm-connection.c	Thu Sep 14 12:50:29 2017 +0300
+++ b/src/director/doveadm-connection.c	Wed Sep 20 01:47:38 2017 +0300
@@ -469,7 +469,8 @@
 				/* there are no more available backends.
 				   kick the user instead. */
 				director_kill_user(dir, dir->self_host, user,
-						   user->host->tag, user->host);
+						   user->host->tag, user->host,
+						   TRUE);
 				users_killed = TRUE;
 			}
 		} T_END;