dovecot: If connect to auth socket fails with a temporary error,...

dovecot at dovecot.org dovecot at dovecot.org
Sun Oct 21 03:00:16 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/d4b2df823ca5
changeset: 6581:d4b2df823ca5
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Oct 21 03:00:09 2007 +0300
description:
If connect to auth socket fails with a temporary error, retry max. 10 times.

diffstat:

1 file changed, 14 insertions(+), 5 deletions(-)
src/deliver/auth-client.c |   19 ++++++++++++++-----

diffs (36 lines):

diff -r d172fb7d216f -r d4b2df823ca5 src/deliver/auth-client.c
--- a/src/deliver/auth-client.c	Sun Oct 21 02:58:49 2007 +0300
+++ b/src/deliver/auth-client.c	Sun Oct 21 03:00:09 2007 +0300
@@ -89,6 +89,7 @@ static bool parse_gid(const char *str, g
 	*gid_r = gr->gr_gid;
 	return TRUE;
 }
+
 static void auth_parse_input(struct auth_connection *conn, const char *args)
 {
 	const char *const *tmp, *extra_groups;
@@ -233,11 +234,19 @@ static struct auth_connection *auth_conn
 static struct auth_connection *auth_connection_new(const char *auth_socket)
 {
 	struct auth_connection *conn;
-	int fd;
-
-	fd = net_connect_unix(auth_socket);
-	if (fd < 0) {
-		i_error("net_connect(%s) failed: %m", auth_socket);
+	int fd, try;
+
+	/* max. 1 second wait here. */
+	for (try = 0; try < 10; try++) {
+		fd = net_connect_unix(auth_socket);
+		if (fd != -1 || (errno != EAGAIN && errno != ECONNREFUSED))
+			break;
+
+		/* busy. wait for a while. */
+		usleep(((rand() % 10) + 1) * 10000);
+	}
+	if (fd == -1) {
+		i_error("Can't connect to auth server at %s: %m", auth_socket);
 		return NULL;
 	}
 


More information about the dovecot-cvs mailing list