dovecot-2.2: director: Avoid crashing if all directors are remov...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 20 03:26:30 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/a71bc8dbe53d
changeset: 14388:a71bc8dbe53d
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 26 17:24:59 2012 +0300
description:
director: Avoid crashing if all directors are removed when reconnecting.
There's no way to currently remove directors though, so this couldn't have
actually happened.

diffstat:

 src/director/director.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (26 lines):

diff -r cd7e15b2d575 -r a71bc8dbe53d src/director/director.c
--- a/src/director/director.c	Mon Mar 26 17:01:21 2012 +0300
+++ b/src/director/director.c	Mon Mar 26 17:24:59 2012 +0300
@@ -115,8 +115,10 @@
 	unsigned int count, self_idx;
 
 	hosts = array_get(&dir->dir_hosts, &count);
-	if (count == 1)
+	if (count == 1) {
+		/* self */
 		return NULL;
+	}
 
 	self_idx = director_find_self_idx(dir);
 	return hosts[(self_idx + 1) % count];
@@ -189,7 +191,9 @@
 	cur_host = dir->right == NULL ? NULL :
 		director_connection_get_host(dir->right);
 
-	if (cur_host != preferred_host)
+	if (preferred_host == NULL) {
+		/* all directors have been removed, try again later */
+	} else if (cur_host != preferred_host)
 		(void)director_connect_host(dir, preferred_host);
 	else {
 		/* the connection hasn't finished sync yet.


More information about the dovecot-cvs mailing list