changeset 18869:697c6f04baca

lib: Added unix_client_connect_msecs setting to connection API.
author Timo Sirainen <tss@iki.fi>
date Tue, 16 Jun 2015 17:19:12 +0300
parents 8076318a7b0e
children 9be3fbad33c5
files src/lib/connection.c src/lib/connection.h
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/connection.c	Tue Jun 16 16:56:08 2015 +0300
+++ b/src/lib/connection.c	Tue Jun 16 17:19:12 2015 +0300
@@ -266,8 +266,10 @@
 
 	if (conn->port != 0)
 		fd = net_connect_ip(&conn->ip, conn->port, NULL);
+	else if (conn->list->set.unix_client_connect_msecs == 0)
+		fd = net_connect_unix(conn->name);
 	else
-		fd = net_connect_unix(conn->name);
+		fd = net_connect_unix_with_retries(conn->name, conn->list->set.unix_client_connect_msecs);
 	if (fd == -1)
 		return -1;
 	conn->fd_in = conn->fd_out = fd;
--- a/src/lib/connection.h	Tue Jun 16 16:56:08 2015 +0300
+++ b/src/lib/connection.h	Tue Jun 16 17:19:12 2015 +0300
@@ -63,6 +63,9 @@
 	   to make the functionality identical with inet sockets, which may
 	   simplify the calling code. */
 	bool delayed_unix_client_connected_callback;
+	/* If connect() to UNIX socket fails with EAGAIN, retry for this many
+	   milliseconds before giving up (0 = try once) */
+	unsigned int unix_client_connect_msecs;
 };
 
 struct connection {