changeset 6625:f40f4e1a0a3c HEAD

If we've been waiting auth server to respond for over 30 seconds, send a "OK Waiting.." message to client.
author Timo Sirainen <tss@iki.fi>
date Sat, 27 Oct 2007 20:03:31 +0300
parents 91a003d00b4e
children 5c25f5d7b29d
files src/imap-login/client.c src/imap-login/client.h
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap-login/client.c	Sat Oct 27 19:06:33 2007 +0300
+++ b/src/imap-login/client.c	Sat Oct 27 20:03:31 2007 +0300
@@ -39,6 +39,10 @@
    client hash, it's faster if we disconnect multiple clients. */
 #define CLIENT_DESTROY_OLDEST_COUNT 16
 
+/* If we've been waiting auth server to respond for over this many seconds,
+   send a "waiting" message. */
+#define AUTH_WAITING_TIMEOUT 30
+
 #if CLIENT_LOGIN_IDLE_TIMEOUT >= AUTH_REQUEST_TIMEOUT
 #  error client idle timeout must be smaller than authentication timeout
 #endif
@@ -344,10 +348,12 @@
 	if (!auth_client_is_connected(auth_client)) {
 		/* we're not yet connected to auth process -
 		   don't allow any commands */
+		client->waiting_sent = TRUE;
 		client_send_line(client,
 			"* OK Waiting for authentication process to respond..");
 		client->input_blocked = TRUE;
 	} else {
+		client->waiting_sent = FALSE;
 		o_stream_cork(client->output);
 		while (client_handle_input(client)) ;
 		o_stream_uncork(client->output);
@@ -576,6 +582,12 @@
 	if (ioloop_time - client->last_input >= CLIENT_LOGIN_IDLE_TIMEOUT) {
 		client_send_line(client, "* BYE Disconnected for inactivity.");
 		client_destroy(client, "Disconnected: Inactivity");
+	} else if (!client->waiting_sent &&
+		   ioloop_time - client->last_input > AUTH_WAITING_TIMEOUT &&
+		   (client->common.authenticating || !client->greeting_sent)) {
+		client->waiting_sent = TRUE;
+		client_send_line(client,
+			"* OK Waiting for authentication process to respond..");
 	}
 }
 
--- a/src/imap-login/client.h	Sat Oct 27 19:06:33 2007 +0300
+++ b/src/imap-login/client.h	Sat Oct 27 20:03:31 2007 +0300
@@ -30,6 +30,7 @@
 	unsigned int input_blocked:1;
 	unsigned int destroyed:1;
 	unsigned int greeting_sent:1;
+	unsigned int waiting_sent:1;
 };
 
 void client_destroy(struct imap_client *client, const char *reason);