dovecot-1.0: If connect to auth socket fails with a temporary er...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Oct 21 03:00:13 EEST 2007
details: http://hg.dovecot.org/dovecot-1.0/rev/8f43fd31eb40
changeset: 5427:8f43fd31eb40
user: Timo Sirainen <tss at iki.fi>
date: Sun Oct 21 03:00:08 2007 +0300
description:
If connect to auth socket fails with a temporary error, retry max. 10 times.
diffstat:
1 file changed, 13 insertions(+), 5 deletions(-)
src/deliver/auth-client.c | 18 +++++++++++++-----
diffs (28 lines):
diff -r c86684296ce8 -r 8f43fd31eb40 src/deliver/auth-client.c
--- a/src/deliver/auth-client.c Sun Oct 21 02:20:23 2007 +0300
+++ b/src/deliver/auth-client.c Sun Oct 21 03:00:08 2007 +0300
@@ -170,11 +170,19 @@ static struct auth_connection *auth_conn
static struct auth_connection *auth_connection_new(const char *auth_socket)
{
struct auth_connection *conn;
- int fd;
-
- fd = net_connect_unix(auth_socket);
- if (fd < 0) {
- i_error("net_connect(%s) failed: %m", auth_socket);
+ int fd, try;
+
+ /* 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;
}
More information about the dovecot-cvs
mailing list