changeset 3468:3e1d7dffb3a2 HEAD

If auth worker socket isn't created yet when we try to connect to it, try for 5 seconds before aborting.
author Timo Sirainen <tss@iki.fi>
date Mon, 04 Jul 2005 00:19:44 +0300
parents b75125eced7f
children 7e39590da48a
files src/auth/auth-worker-server.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/auth-worker-server.c	Mon Jul 04 00:09:40 2005 +0300
+++ b/src/auth/auth-worker-server.c	Mon Jul 04 00:19:44 2005 +0300
@@ -48,19 +48,27 @@
 static struct auth_worker_connection *auth_worker_create(void)
 {
 	struct auth_worker_connection *conn;
-	int fd;
+	int fd, try;
 
 	if (connections->used / sizeof(conn) >= auth_workers_max)
 		return NULL;
 
-	fd = net_connect_unix(worker_socket_path);
-	if (fd < 0) {
+	for (try = 0;; try++) {
+		fd = net_connect_unix(worker_socket_path);
+		if (fd >= 0)
+			break;
+
 		if (errno != EAGAIN) {
 			i_fatal("net_connect_unix(%s) failed: %m",
 				worker_socket_path);
 		}
-		/* busy */
-		return NULL;
+		if (errno != ENOENT || try == 5) {
+			/* busy / broken */
+			return NULL;
+		}
+
+		/* not created yet? try again */
+		sleep(1);
 	}
 
 	conn = i_new(struct auth_worker_connection, 1);