changeset 3533:3ec5c6665bec HEAD

If UNIX socket connection fails with EAGAIN, try again for a while.
author Timo Sirainen <tss@iki.fi>
date Sun, 14 Aug 2005 23:39:22 +0300
parents 4f7427a5be61
children a9be1824403b
files src/lib-auth/auth-server-connection.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-auth/auth-server-connection.c	Sun Aug 14 23:34:33 2005 +0300
+++ b/src/lib-auth/auth-server-connection.c	Sun Aug 14 23:39:22 2005 +0300
@@ -192,9 +192,17 @@
 	struct auth_server_connection *conn;
 	const char *handshake;
 	pool_t pool;
-	int fd;
+	int fd, try;
 
-	fd = net_connect_unix(path);
+	/* max. 1 second wait here. */
+	for (try = 0; try < 10; try++) {
+		fd = net_connect_unix(path);
+		if (fd != -1 || errno != EAGAIN)
+			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", path);
 		return NULL;