From 5c1733e9e572e242598b8b2f12a0068897caf5b7 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 15 May 2015 16:44:45 +0300 Subject: [PATCH] director: Moving a user to another host sometimes caused the move to fail. It could have given "User hash .. is being redirected to two hosts" error and afterwards moved the user back to its original host. --- src/director/director-connection.c | 9 +++++++++ src/director/user-directory.h | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/director/director-connection.c b/src/director/director-connection.c index 7fd9124584..676b5417f0 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -506,6 +506,15 @@ 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 && + user->kill_state < USER_KILL_STATE_DELAY) { + /* 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, " + "preserve its host %s instead of replacing with %s", + username_hash, net_ip2addr(&user->host->ip), + net_ip2addr(&host->ip)); + host = user->host; } else { /* non-weak user received a non-weak update with conflicting host. this shouldn't happen. */ diff --git a/src/director/user-directory.h b/src/director/user-directory.h index 1b9c147e74..b643cf5f86 100644 --- a/src/director/user-directory.h +++ b/src/director/user-directory.h @@ -16,7 +16,10 @@ enum user_kill_state { /* We're done killing, but waiting for USER-KILLED-EVERYWHERE notification until this state gets reset. */ USER_KILL_STATE_KILLED_WAITING_FOR_EVERYONE, - /* Wait for a while for the user connections to actually die */ + /* Wait for a while for the user connections to actually die. Note that + only at this stage we can be sure that all the directors know about + the user move (although it could be earlier if we added a new + USER-MOVED notification). */ USER_KILL_STATE_DELAY }; -- 2.47.3