dovecot: If auth server hasn't responded to handshake in 30 seco...
dovecot at dovecot.org
dovecot at dovecot.org
Sat Oct 27 20:05:02 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/5c25f5d7b29d
changeset: 6626:5c25f5d7b29d
user: Timo Sirainen <tss at iki.fi>
date: Sat Oct 27 20:04:56 2007 +0300
description:
If auth server hasn't responded to handshake in 30 seconds, log an error and
reconnect.
diffstat:
2 files changed, 18 insertions(+)
src/lib-auth/auth-server-connection.c | 17 +++++++++++++++++
src/lib-auth/auth-server-connection.h | 1 +
diffs (66 lines):
diff -r f40f4e1a0a3c -r 5c25f5d7b29d src/lib-auth/auth-server-connection.c
--- 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
@@ -13,6 +13,8 @@
#include <unistd.h>
#include <stdlib.h>
+
+#define AUTH_HANDSHAKE_TIMEOUT (30*1000)
static void auth_server_connection_unref(struct auth_server_connection *conn);
@@ -111,6 +113,9 @@ static bool auth_client_input_done(struc
i_error("BUG: Authentication server returned no mechanisms");
return FALSE;
}
+
+ if (conn->to != NULL)
+ timeout_remove(&conn->to);
conn->handshake_received = TRUE;
conn->client->conn_waiting_handshake_count--;
@@ -192,6 +197,14 @@ static void auth_client_input(struct aut
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 @@ auth_server_connection_new(struct auth_c
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 @@ void auth_server_connection_destroy(stru
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);
diff -r f40f4e1a0a3c -r 5c25f5d7b29d src/lib-auth/auth-server-connection.h
--- a/src/lib-auth/auth-server-connection.h Sat Oct 27 20:03:31 2007 +0300
+++ b/src/lib-auth/auth-server-connection.h Sat Oct 27 20:04:56 2007 +0300
@@ -31,6 +31,7 @@ struct auth_server_connection {
int fd;
struct io *io;
+ struct timeout *to;
struct istream *input;
struct ostream *output;
More information about the dovecot-cvs
mailing list