dovecot-2.0: director: Use net_try_bind() to try to find our own...

dovecot at dovecot.org dovecot at dovecot.org
Wed May 19 19:24:42 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/7d3d6ee01bfc
changeset: 11341:7d3d6ee01bfc
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 19 18:24:39 2010 +0200
description:
director: Use net_try_bind() to try to find our own IP.

diffstat:

 src/director/director.c |  17 +++++------------
 1 files changed, 5 insertions(+), 12 deletions(-)

diffs (31 lines):

diff -r 40964653930c -r 7d3d6ee01bfc src/director/director.c
--- a/src/director/director.c	Wed May 19 18:24:23 2010 +0200
+++ b/src/director/director.c	Wed May 19 18:24:39 2010 +0200
@@ -31,22 +31,15 @@
 {
 	struct director_host *const *hosts;
 	unsigned int i, count;
-	int fd = -1;
 
 	hosts = array_get(&dir->dir_hosts, &count);
 	for (i = 0; i < count; i++) {
-		fd = net_connect_ip(&hosts[i]->ip, hosts[i]->port,
-				    &hosts[i]->ip);
-		if (fd != -1)
-			break;
+		if (net_try_bind(&hosts[i]->ip) == 0) {
+			dir->self_ip = hosts[i]->ip;
+			return;
+		}
 	}
-
-	if (fd == -1)
-		i_fatal("director_servers doesn't list ourself");
-
-	if (net_getsockname(fd, &dir->self_ip, NULL) < 0)
-		i_fatal("getsockname() failed: %m");
-	net_disconnect(fd);
+	i_fatal("director_servers doesn't list ourself");
 }
 
 static void director_find_self(struct director *dir)


More information about the dovecot-cvs mailing list