Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6626:5c25f5d7b29d HEAD
If auth server hasn't responded to handshake in 30 seconds, log an error and
reconnect.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 27 Oct 2007 20:04:56 +0300 |
parents | f40f4e1a0a3c |
children | 7124f607fb1b |
files | src/lib-auth/auth-server-connection.c src/lib-auth/auth-server-connection.h |
diffstat | 2 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-auth/auth-server-connection.c Sat Oct 27 20:03:31 2007 +0300 +++ b/src/lib-auth/auth-server-connection.c Sat Oct 27 20:04:56 2007 +0300 @@ -14,6 +14,8 @@ #include <unistd.h> #include <stdlib.h> +#define AUTH_HANDSHAKE_TIMEOUT (30*1000) + static void auth_server_connection_unref(struct auth_server_connection *conn); static void update_available_auth_mechs(struct auth_server_connection *conn) @@ -112,6 +114,9 @@ return FALSE; } + if (conn->to != NULL) + timeout_remove(&conn->to); + conn->handshake_received = TRUE; conn->client->conn_waiting_handshake_count--; update_available_auth_mechs(conn); @@ -192,6 +197,14 @@ auth_server_connection_unref(conn); } +static void auth_client_handshake_timeout(struct auth_server_connection *conn) +{ + i_error("Timeout waiting for handshake from auth server. " + "my pid=%u, input bytes=%"PRIuUOFF_T, + conn->client->pid, conn->input->v_offset); + auth_server_connection_destroy(&conn, TRUE); +} + struct auth_server_connection * auth_server_connection_new(struct auth_client *client, const char *path) { @@ -232,6 +245,8 @@ conn->requests = hash_create(default_pool, pool, 100, NULL, NULL); conn->auth_mechs_buf = buffer_create_dynamic(default_pool, 256); + conn->to = timeout_add(AUTH_HANDSHAKE_TIMEOUT, + auth_client_handshake_timeout, conn); conn->next = client->connections; client->connections = conn; @@ -273,6 +288,8 @@ if (!conn->handshake_received) client->conn_waiting_handshake_count--; + if (conn->to != NULL) + timeout_remove(&conn->to); if (conn->io != NULL) io_remove(&conn->io);