dovecot-1.0: If auth server hasn't responded to handshake in 30 ...

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 27 20:05:03 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/4dab9295cd95
changeset: 5431:4dab9295cd95
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, 20 insertions(+)
src/lib-auth/auth-server-connection.c |   19 +++++++++++++++++++
src/lib-auth/auth-server-connection.h |    1 +

diffs (68 lines):

diff -r 4bdab7e04a61 -r 4dab9295cd95 src/lib-auth/auth-server-connection.c
--- a/src/lib-auth/auth-server-connection.c	Sat Oct 27 20:03:32 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--;
@@ -193,6 +198,16 @@ static void auth_client_input(void *cont
 	auth_server_connection_unref(conn);
 }
 
+static void auth_client_handshake_timeout(void *context)
+{
+	struct auth_server_connection *conn = context;
+
+	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)
 {
@@ -239,6 +254,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;
 
@@ -284,6 +301,8 @@ void auth_server_connection_destroy(stru
 		client->ext_input_remove(conn->ext_input_io);
 		conn->ext_input_io = NULL;
 	}
+	if (conn->to != NULL)
+		timeout_remove(&conn->to);
 	if (conn->io != NULL)
 		io_remove(&conn->io);
 
diff -r 4bdab7e04a61 -r 4dab9295cd95 src/lib-auth/auth-server-connection.h
--- a/src/lib-auth/auth-server-connection.h	Sat Oct 27 20:03:32 2007 +0300
+++ b/src/lib-auth/auth-server-connection.h	Sat Oct 27 20:04:56 2007 +0300
@@ -35,6 +35,7 @@ struct auth_server_connection {
 	int fd;
 
 	struct io *io;
+	struct timeout *to;
 	void *ext_input_io;
 	struct istream *input;
 	struct ostream *output;


More information about the dovecot-cvs mailing list