Mercurial > dovecot > core-2.2
changeset 20992:5b6eaea4c59b
director: Send user's old and new backend IPs to flush script.
If user was created due to the user-move, don't execute the flush script
since it wouldn't really have any work to do anyway.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Tue, 25 Oct 2016 22:17:23 +0300 |
parents | 9fb54c8827fb |
children | ff822a101e3e |
files | src/director/director.c src/director/director.h |
diffstat | 2 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/director/director.c Tue Oct 25 22:12:01 2016 +0300 +++ b/src/director/director.c Tue Oct 25 22:17:23 2016 +0300 @@ -769,8 +769,14 @@ /* Execute flush script, if set. Only the director that started the user moving will call the flush script. Having each director do it would be redundant since they're all supposed to be performing the - same flush task to the same backend. */ + same flush task to the same backend. + + Flushing is also not triggered if we're moving a user that we just + created due to the user move. This means that the user doesn't have + an old host, so we couldn't really even perform any flushing on the + backend. */ if (*dir->set->director_flush_socket == '\0' || + ctx->old_host_ip.family == 0 || !ctx->kill_is_self_initiated) { director_user_kill_finish_delayed(dir, user, FALSE); return; @@ -789,8 +795,13 @@ restrict_access_init(&set.restrict_set); - const char *const args[] = {"FLUSH", - t_strdup_printf("%u", user->username_hash), NULL}; + const char *const args[] = { + "FLUSH", + t_strdup_printf("%u", user->username_hash), + net_ip2addr(&ctx->old_host_ip), + net_ip2addr(&user->host->ip), + NULL + }; ctx->kill_state = USER_KILL_STATE_FLUSHING; dir_debug("Flushing user %u via %s", user->username_hash, @@ -980,6 +991,8 @@ ctx->dir = dir; ctx->username_hash = user->username_hash; ctx->kill_is_self_initiated = src->self; + if (old_host != NULL) + ctx->old_host_ip = old_host->ip; dir->users_moving_count++; ctx->to_move = timeout_add(DIRECTOR_USER_MOVE_TIMEOUT_MSECS,
--- a/src/director/director.h Tue Oct 25 22:12:01 2016 +0300 +++ b/src/director/director.h Tue Oct 25 22:17:23 2016 +0300 @@ -73,6 +73,7 @@ struct director_kill_context { struct director *dir; unsigned int username_hash; + struct ip_addr old_host_ip; bool kill_is_self_initiated; bool callback_pending;