# HG changeset patch # User Timo Sirainen # Date 1192924809 -10800 # Node ID d4b2df823ca524aef7bd39f49afddf6d5ae71248 # Parent d172fb7d216f442f0175998a5bba6fa11b2829c8 If connect to auth socket fails with a temporary error, retry max. 10 times. 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 @@ *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_connection_new(const char *auth_socket) { struct auth_connection *conn; - int fd; + int fd, try; - fd = net_connect_unix(auth_socket); - if (fd < 0) { - i_error("net_connect(%s) failed: %m", auth_socket); + /* 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; }