dovecot-1.0: If we've been waiting auth server to respond for ov...

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


details:   http://hg.dovecot.org/dovecot-1.0/rev/4bdab7e04a61
changeset: 5430:4bdab7e04a61
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 27 20:03:32 2007 +0300
description:
If we've been waiting auth server to respond for over 30 seconds, send a "OK
Waiting.." message to client.

diffstat:

2 files changed, 13 insertions(+)
src/imap-login/client.c |   12 ++++++++++++
src/imap-login/client.h |    1 +

diffs (51 lines):

diff -r d58f7f66faa3 -r 4bdab7e04a61 src/imap-login/client.c
--- a/src/imap-login/client.c	Sat Oct 27 19:06:37 2007 +0300
+++ b/src/imap-login/client.c	Sat Oct 27 20:03:32 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
@@ -347,10 +351,12 @@ void client_input(void *context)
 	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);
@@ -575,6 +581,12 @@ static void client_check_idle(struct ima
 	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..");
 	}
 }
 
diff -r d58f7f66faa3 -r 4bdab7e04a61 src/imap-login/client.h
--- a/src/imap-login/client.h	Sat Oct 27 19:06:37 2007 +0300
+++ b/src/imap-login/client.h	Sat Oct 27 20:03:32 2007 +0300
@@ -30,6 +30,7 @@ struct imap_client {
 	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);


More information about the dovecot-cvs mailing list