Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6581:d4b2df823ca5 HEAD
If connect to auth socket fails with a temporary error, retry max. 10 times.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 21 Oct 2007 03:00:09 +0300 |
parents | d172fb7d216f |
children | 9e7bf6becfb4 |
files | src/deliver/auth-client.c |
diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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; }