]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Send user's old and new backend IPs to flush script.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 25 Oct 2016 19:17:23 +0000 (22:17 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 26 Oct 2016 10:08:24 +0000 (13:08 +0300)
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.

src/director/director.c
src/director/director.h

index bce492c3e4f7fcf00bac1166c2e88d35267c4023..7a42cf3bc6b182812abba3ebb020eb95dd7c94d2 100644 (file)
@@ -769,8 +769,14 @@ director_flush_user(struct director *dir, struct user *user)
        /* 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 @@ director_flush_user(struct director *dir, struct user *user)
 
        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 @@ director_kill_user(struct director *dir, struct director_host *src,
        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,
index bed2875125c6a16370198c62138151a9adef5b81..6918c7c6c7890355ebd285e88aad656fecd265a5 100644 (file)
@@ -73,6 +73,7 @@ typedef void director_state_change_callback_t(struct director *dir);
 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;