]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Execute director_flush_socket only from one director.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 24 Oct 2016 21:48:08 +0000 (00:48 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 25 Oct 2016 18:01:23 +0000 (21:01 +0300)
Having each director do it would be redundant since they're all supposed to
be performing the same flush task to the same backend.

src/director/director.c
src/director/user-directory.h

index 672794e2fab6cb4c0192ab97a1c1bcbb258430ab..0eddfac46728525e353bc26a3ffcd36fe98a15b1 100644 (file)
@@ -764,8 +764,12 @@ director_flush_user(struct director *dir, struct user *user)
                { '\0', NULL, NULL }
        };
 
-       /* execute flush script, if set */
-       if (*dir->set->director_flush_socket == '\0') {
+       /* 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. */
+       if (*dir->set->director_flush_socket == '\0' ||
+           !user->kill_is_self_initiated) {
                director_user_kill_finish_delayed(dir, user, FALSE);
                return;
        }
@@ -821,6 +825,7 @@ static void director_user_move_free(struct director *dir, struct user *user)
        dir_debug("User %u move finished at state=%s", user->username_hash,
                  user_kill_state_names[user->kill_state]);
 
+       user->kill_is_self_initiated = FALSE;
        user->kill_state = USER_KILL_STATE_NONE;
        timeout_remove(&user->to_move);
 
@@ -1004,6 +1009,7 @@ void director_move_user(struct director *dir, struct director_host *src,
                dir->users_moving_count++;
                user->to_move = timeout_add(DIRECTOR_USER_MOVE_TIMEOUT_MSECS,
                                            director_user_move_timeout, user);
+               user->kill_is_self_initiated = src->self;
                user->kill_state = USER_KILL_STATE_KILLING;
                cmd = t_strdup_printf("proxy\t*\tKICK-DIRECTOR-HASH\t%u",
                                      username_hash);
index fe15babf5e9bcb23e59289d7c265138f3d04da9a..ef5b4bf88b4bd0825465fe77ca308a0c09a9dc82 100644 (file)
@@ -50,6 +50,8 @@ struct user {
           now doing a ring-wide sync for this user to make sure we don't
           assign conflicting hosts to it */
        unsigned int weak:1;
+       /* TRUE, if this server initiated the user's kill. */
+       unsigned int kill_is_self_initiated:1;
 };
 
 /* Create a new directory. Users are dropped if their time gets older