]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Code cleanup - added USER_IS_BEING_KILLED() macro
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 20 Oct 2016 13:46:31 +0000 (16:46 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 26 Oct 2016 10:10:37 +0000 (13:10 +0300)
src/director/director-connection.c
src/director/director-request.c
src/director/director.c
src/director/doveadm-connection.c
src/director/user-directory.c
src/director/user-directory.h

index 7a71f9e4dfef723ab589e08c678716fd9ca0b62b..0df8ed010c334501f5593f6f949957f3ef0bd03c 100644 (file)
@@ -549,7 +549,7 @@ director_user_refresh(struct director_connection *conn,
                          "replacing host %s with %s", username_hash,
                          net_ip2addr(&user->host->ip), net_ip2addr(&host->ip));
                ret = TRUE;
-       } else if (user->kill_state != USER_KILL_STATE_NONE) {
+       } else if (USER_IS_BEING_KILLED(user)) {
                /* user is still being moved - ignore conflicting host updates
                   from other directors who don't yet know about the move. */
                dir_debug("user refresh: %u is being moved, "
@@ -574,7 +574,7 @@ director_user_refresh(struct director_connection *conn,
                }
                if (user->to_move != NULL)
                        str_append(str, ",moving");
-               if (user->kill_state != USER_KILL_STATE_NONE) {
+               if (USER_IS_BEING_KILLED(user)) {
                        str_printfa(str, ",kill_state=%s",
                                    user_kill_state_names[user->kill_state]);
                }
index 62afcc906d8b02b08be4fca00001e30f58b53ad5..c7c6d952c5478761d5ada8d9646355e9f5937d41 100644 (file)
@@ -179,7 +179,7 @@ director_request_existing(struct director_request *request, struct user *user,
        struct director *dir = request->dir;
        struct mail_host *host;
 
-       if (user->kill_state != USER_KILL_STATE_NONE) {
+       if (USER_IS_BEING_KILLED(user)) {
                /* delay processing this user's connections until
                   its existing connections have been killed */
                request->delay_reason = REQUEST_DELAY_KILL;
index 451a587151856cf4157c306c8bb17913ff75aff4..1df240f60acf5d19086bd16b3167bf1f359cfbdd 100644 (file)
@@ -1010,7 +1010,7 @@ void director_move_user(struct director *dir, struct director_host *src,
                user->host->user_count++;
                user->timestamp = ioloop_time;
        }
-       if (user->kill_state == USER_KILL_STATE_NONE) {
+       if (!USER_IS_BEING_KILLED(user)) {
                ctx = i_new(struct director_kill_context, 1);
                ctx->dir = dir;
                ctx->username_hash = username_hash;
index 5de38c902e0703ded4abcbdb5dd3653e16031baa..2fa9c3e4813c1126048b9dc0f6cde3395646c733 100644 (file)
@@ -651,7 +651,7 @@ doveadm_cmd_user_move(struct doveadm_connection *conn, const char *const *args)
        if (str_to_uint(args[0], &username_hash) < 0)
                username_hash = user_directory_get_username_hash(conn->dir->users, args[0]);
        user = user_directory_lookup(conn->dir->users, username_hash);
-       if (user != NULL && user->kill_state != USER_KILL_STATE_NONE) {
+       if (user != NULL && USER_IS_BEING_KILLED(user)) {
                o_stream_nsend_str(conn->output, "TRYAGAIN\n");
                return 1;
        }
index 67798083d68bd586a5ad99109da3e77603b90398..3c60259a9ca017eeefbfa324e6e136b3cb04e3c2 100644 (file)
@@ -74,7 +74,7 @@ static bool user_directory_user_has_connections(struct user_directory *dir,
        if (expire_timestamp > ioloop_time)
                return TRUE;
 
-       if (user->kill_state != USER_KILL_STATE_NONE) {
+       if (USER_IS_BEING_KILLED(user)) {
                /* don't free this user until the kill is finished */
                return TRUE;
        }
index 21df29d85e6ff1c6bdf076aaceefa6b465f8ef71..f4d323cb706fdb890b1c4d157eb706b0a496f656 100644 (file)
@@ -3,6 +3,9 @@
 
 #include "director.h"
 
+#define USER_IS_BEING_KILLED(user) \
+       ((user)->kill_state != USER_KILL_STATE_NONE)
+
 struct user {
        /* sorted by time */
        struct user *prev, *next;