dovecot-2.0: lib-master: Try for 0.5 secs to connect to master-a...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 23 12:40:26 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/823356f533c5
changeset: 10573:823356f533c5
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jan 23 12:40:22 2010 +0200
description:
lib-master: Try for 0.5 secs to connect to master-auth socket.

diffstat:

1 file changed, 10 insertions(+), 5 deletions(-)
src/lib-master/master-auth.c |   15 ++++++++++-----

diffs (33 lines):

diff -r 26b5209dc4f4 -r 823356f533c5 src/lib-master/master-auth.c
--- a/src/lib-master/master-auth.c	Sat Jan 23 12:37:35 2010 +0200
+++ b/src/lib-master/master-auth.c	Sat Jan 23 12:40:22 2010 +0200
@@ -11,6 +11,8 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/stat.h>
+
+#define SOCKET_CONNECT_RETRY_MSECS 500
 
 struct master_auth_connection {
 	struct master_auth *auth;
@@ -172,12 +174,15 @@ void master_auth_request(struct master_a
 	buffer_append(buf, &req, sizeof(req));
 	buffer_append(buf, data, req.data_size);
 
-	conn->fd = net_connect_unix(auth->path);
-	if (conn->fd == -1)
+	conn->fd = net_connect_unix_with_retries(auth->path,
+						 SOCKET_CONNECT_RETRY_MSECS);
+	if (conn->fd == -1) {
 		i_error("net_connect_unix(%s) failed: %m", auth->path);
-
-	ret = conn->fd == -1 ? -1 :
-		fd_send(conn->fd, fd, buf->data, buf->used);
+		master_auth_connection_deinit(&conn);
+		return;
+	}
+
+	ret = fd_send(conn->fd, fd, buf->data, buf->used);
 	if (ret < 0)
 		i_error("fd_send(%d) failed: %m", fd);
 	else if ((size_t)ret != buf->used) {


More information about the dovecot-cvs mailing list