]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login: Added logging if auth process doesn't respond fast enough for greeting.
authorTimo Sirainen <tss@iki.fi>
Thu, 12 Jan 2012 19:53:31 +0000 (21:53 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 12 Jan 2012 19:53:31 +0000 (21:53 +0200)
src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/client-common.h

index a2e5f32036a3fd97b0991ee233a7a91ad813b986..90bcc3c5e8e20bd3b7db8e1c52cdf7aa99cc564d 100644 (file)
@@ -17,6 +17,7 @@
 /* If we've been waiting auth server to respond for over this many milliseconds,
    send a "waiting" message. */
 #define AUTH_WAITING_TIMEOUT_MSECS (30*1000)
+#define GREETING_WARNING_TIMEOUT_MSECS (10*1000)
 
 #define CLIENT_AUTH_BUF_MAX_SIZE 8192
 
@@ -36,6 +37,10 @@ void client_auth_failed(struct client *client)
 
 static void client_auth_waiting_timeout(struct client *client)
 {
+       if (!client->greeting_sent) {
+               client_log_warn(client, "Auth process not responding, "
+                               "delayed sending greeting");
+       }
        client_send_line(client, CLIENT_CMD_REPLY_STATUS,
                         client->master_tag == 0 ?
                         AUTH_SERVER_WAITING_MSG : AUTH_MASTER_WAITING_MSG);
@@ -46,7 +51,9 @@ void client_set_auth_waiting(struct client *client)
 {
        i_assert(client->to_auth_waiting == NULL);
        client->to_auth_waiting =
-               timeout_add(AUTH_WAITING_TIMEOUT_MSECS,
+               timeout_add(!client->greeting_sent ?
+                           GREETING_WARNING_TIMEOUT_MSECS :
+                           AUTH_WAITING_TIMEOUT_MSECS,
                            client_auth_waiting_timeout, client);
 }
 
index fa35c9f1887c5083a4f71a9b0d6f84c707d534dd..a5e680da490a2ad7e9512900c3a6d17083420e5d 100644 (file)
@@ -484,6 +484,13 @@ void client_log_err(struct client *client, const char *msg)
        } T_END;
 }
 
+void client_log_warn(struct client *client, const char *msg)
+{
+       T_BEGIN {
+               i_warning("%s", client_get_log_str(client, msg));
+       } T_END;
+}
+
 bool client_is_trusted(struct client *client)
 {
        const char *const *net;
@@ -520,6 +527,11 @@ const char *client_get_extra_disconnect_reason(struct client *client)
                        return "(client didn't send a cert)";
        }
 
+       if (!client->greeting_sent)
+               return t_strdup_printf(
+                       "(disconnected before greeting, waited %u secs)",
+                       (unsigned int)(ioloop_time - client->created));
+
        if (client->auth_attempts == 0) {
                return t_strdup_printf("(no auth attempts in %u secs)",
                        (unsigned int)(ioloop_time - client->created));
index 71f52341d712a4b03230a9bf58674b2f04a72ee2..880119f1986f902d1bea8f44c34ee3be56d454c6 100644 (file)
@@ -152,6 +152,7 @@ unsigned int clients_get_count(void) ATTR_PURE;
 void client_set_title(struct client *client);
 void client_log(struct client *client, const char *msg);
 void client_log_err(struct client *client, const char *msg);
+void client_log_warn(struct client *client, const char *msg);
 const char *client_get_extra_disconnect_reason(struct client *client);
 bool client_is_trusted(struct client *client);
 void client_auth_failed(struct client *client);