From: Timo Sirainen Date: Thu, 20 Oct 2016 13:46:31 +0000 (+0300) Subject: director: Code cleanup - added USER_IS_BEING_KILLED() macro X-Git-Tag: 2.2.26~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6f99e4d917db4dcce6570685620085983f4c9db;p=thirdparty%2Fdovecot%2Fcore.git director: Code cleanup - added USER_IS_BEING_KILLED() macro --- diff --git a/src/director/director-connection.c b/src/director/director-connection.c index 7a71f9e4df..0df8ed010c 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -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]); } diff --git a/src/director/director-request.c b/src/director/director-request.c index 62afcc906d..c7c6d952c5 100644 --- a/src/director/director-request.c +++ b/src/director/director-request.c @@ -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; diff --git a/src/director/director.c b/src/director/director.c index 451a587151..1df240f60a 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -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; diff --git a/src/director/doveadm-connection.c b/src/director/doveadm-connection.c index 5de38c902e..2fa9c3e481 100644 --- a/src/director/doveadm-connection.c +++ b/src/director/doveadm-connection.c @@ -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; } diff --git a/src/director/user-directory.c b/src/director/user-directory.c index 67798083d6..3c60259a9c 100644 --- a/src/director/user-directory.c +++ b/src/director/user-directory.c @@ -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; } diff --git a/src/director/user-directory.h b/src/director/user-directory.h index 21df29d85e..f4d323cb70 100644 --- a/src/director/user-directory.h +++ b/src/director/user-directory.h @@ -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;