From: Timo Sirainen Date: Thu, 12 Jan 2012 19:53:31 +0000 (+0200) Subject: login: Added logging if auth process doesn't respond fast enough for greeting. X-Git-Tag: 2.1.rc4~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9c76fe9d9ca194816606342da1ddbd9be6bc8ab;p=thirdparty%2Fdovecot%2Fcore.git login: Added logging if auth process doesn't respond fast enough for greeting. --- diff --git a/src/login-common/client-common-auth.c b/src/login-common/client-common-auth.c index a2e5f32036..90bcc3c5e8 100644 --- a/src/login-common/client-common-auth.c +++ b/src/login-common/client-common-auth.c @@ -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); } diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index fa35c9f188..a5e680da49 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -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)); diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index 71f52341d7..880119f198 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -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);