Mercurial > dovecot > core-2.2
changeset 17259:6269063f8408
director: Fixed handling weak users when there were exactly 2 director servers in the ring.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 23 Apr 2014 23:26:49 +0300 |
parents | 45bedf335e92 |
children | aec6f57b8cf8 |
files | src/director/director-connection.c src/director/director-request.c src/director/director.c src/director/director.h |
diffstat | 4 files changed, 26 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/director/director-connection.c Wed Apr 23 22:33:48 2014 +0300 +++ b/src/director/director-connection.c Wed Apr 23 23:26:49 2014 +0300 @@ -799,7 +799,7 @@ if (!user->weak) director_update_user(conn->dir, src_host, user); else { - director_update_user_weak(conn->dir, src_host, + director_update_user_weak(conn->dir, src_host, conn, dir_host, user); } }
--- a/src/director/director-request.c Wed Apr 23 22:33:48 2014 +0300 +++ b/src/director/director-request.c Wed Apr 23 23:26:49 2014 +0300 @@ -241,7 +241,7 @@ return TRUE; } else { user->weak = TRUE; - director_update_user_weak(dir, dir->self_host, NULL, user); + director_update_user_weak(dir, dir->self_host, NULL, NULL, user); request->delay_reason = REQUEST_DELAY_WEAK; dir_debug("request: %u set to weak", request->username_hash); return FALSE;
--- a/src/director/director.c Wed Apr 23 22:33:48 2014 +0300 +++ b/src/director/director.c Wed Apr 23 23:26:49 2014 +0300 @@ -566,9 +566,12 @@ } void director_update_user_weak(struct director *dir, struct director_host *src, + struct director_connection *src_conn, struct director_host *orig_src, struct user *user) { + const char *cmd; + i_assert(src != NULL); i_assert(user->weak); @@ -577,10 +580,27 @@ orig_src->last_seq++; } - director_update_send(dir, src, t_strdup_printf( - "USER-WEAK\t%s\t%u\t%u\t%u\t%s\n", + cmd = t_strdup_printf("USER-WEAK\t%s\t%u\t%u\t%u\t%s\n", net_ip2addr(&orig_src->ip), orig_src->port, orig_src->last_seq, - user->username_hash, net_ip2addr(&user->host->ip))); + user->username_hash, net_ip2addr(&user->host->ip)); + + if (src != dir->self_host && dir->left != NULL && dir->right != NULL && + director_connection_get_host(dir->left) == + director_connection_get_host(dir->right)) { + /* only two directors in this ring and we're forwarding + USER-WEAK from one director back to itself via another + so it sees we've received it. we can't use + director_update_send() for this, because it doesn't send + data back to the source. */ + if (dir->right == src_conn) + director_connection_send(dir->left, cmd); + else if (dir->left == src_conn) + director_connection_send(dir->right, cmd); + else + i_unreached(); + } else { + director_update_send(dir, src, cmd); + } } struct director_user_kill_finish_ctx {
--- a/src/director/director.h Wed Apr 23 22:33:48 2014 +0300 +++ b/src/director/director.h Wed Apr 23 23:26:49 2014 +0300 @@ -124,6 +124,7 @@ void director_update_user(struct director *dir, struct director_host *src, struct user *user); void director_update_user_weak(struct director *dir, struct director_host *src, + struct director_connection *src_conn, struct director_host *orig_src, struct user *user) ATTR_NULL(3); void director_move_user(struct director *dir, struct director_host *src,