[dovecot-cvs] dovecot/src/deliver auth-client.c,1.5,1.6

tss at dovecot.org tss at dovecot.org
Thu Nov 2 18:11:07 UTC 2006


Update of /var/lib/cvs/dovecot/src/deliver
In directory talvi:/tmp/cvs-serv31840

Modified Files:
	auth-client.c 
Log Message:
If we can't get auth user reply in a minute log timeout error and quit.



Index: auth-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/deliver/auth-client.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- auth-client.c	15 Oct 2006 15:55:00 -0000	1.5
+++ auth-client.c	2 Nov 2006 18:11:05 -0000	1.6
@@ -13,6 +13,7 @@
 #include <unistd.h>
 #include <sysexits.h>
 
+#define AUTH_REQUEST_TIMEOUT 60
 #define MAX_INBUF_SIZE 8192
 #define MAX_OUTBUF_SIZE 512
 
@@ -20,6 +21,7 @@
 
 struct auth_connection {
 	int fd;
+	struct timeout *to;
 	struct io *io;
 	struct istream *input;
 	struct ostream *output;
@@ -35,6 +37,8 @@
 {
 	io_loop_stop(conn->ioloop);
 
+	if (conn->to != NULL)
+		timeout_remove(&conn->to);
 	io_remove(&conn->io);
 	i_stream_unref(&conn->input);
 	o_stream_unref(&conn->output);
@@ -184,6 +188,17 @@
 	return conn;
 }
 
+static void auth_client_timeout(void *context)
+{
+	struct auth_connection *conn = context;
+
+	if (!conn->handshaked)
+		i_error("Connecting to dovecot-auth timed out");
+	else
+		i_error("User request from dovecot-auth timed out");
+	auth_connection_destroy(conn);
+}
+
 int auth_client_put_user_env(struct ioloop *ioloop, const char *auth_socket,
 			     const char *user, uid_t euid)
 {
@@ -196,6 +211,8 @@
 	conn->ioloop = ioloop;
 	conn->euid = euid;
 	conn->user = user;
+	conn->to = timeout_add(1000*AUTH_REQUEST_TIMEOUT,
+			       auth_client_timeout, conn);
 
 	o_stream_send_str(conn->output,
 			  t_strconcat("VERSION\t1\t0\n"



More information about the dovecot-cvs mailing list