dovecot-2.2: log: Log a warning if some connection is logging fa...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 7 16:39:17 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/dec13d8f524c
changeset: 18231:dec13d8f524c
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 07 18:39:05 2015 +0200
description:
log: Log a warning if some connection is logging faster than we can write.

diffstat:

 src/log/log-connection.c |  17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r 787ce1ab9f85 -r dec13d8f524c src/log/log-connection.c
--- a/src/log/log-connection.c	Sat Feb 07 18:23:58 2015 +0200
+++ b/src/log/log-connection.c	Sat Feb 07 18:39:05 2015 +0200
@@ -19,6 +19,12 @@
 #define FATAL_QUEUE_TIMEOUT_MSECS 500
 #define MAX_MSECS_PER_CONNECTION 100
 
+/* Log a warning after 1 secs when we've been all the time busy writing the
+   log connection. */
+#define LOG_WARN_PENDING_COUNT (1000 / MAX_MSECS_PER_CONNECTION)
+/* If we keep beeing busy, log a warning every 60 seconds. */
+#define LOG_WARN_PENDING_INTERVAL (60 * LOG_WARN_PENDING_COUNT)
+
 struct log_client {
 	struct ip_addr ip;
 	char *prefix;
@@ -37,6 +43,8 @@
 	char *default_prefix;
 	HASH_TABLE(void *, struct log_client *) clients;
 
+	unsigned int pending_count;
+
 	unsigned int master:1;
 	unsigned int handshaked:1;
 };
@@ -318,6 +326,15 @@
 		log_connection_destroy(log);
 	} else {
 		i_assert(!log->input->closed);
+		if (ret == 0)
+			log->pending_count = 0;
+		else if (++log->pending_count >= LOG_WARN_PENDING_COUNT) {
+			if (log->pending_count == LOG_WARN_PENDING_COUNT ||
+			    (log->pending_count % LOG_WARN_PENDING_INTERVAL) == 0) {
+				i_warning("Log connection fd %d listen_fd %d prefix '%s' is sending input faster than we can write",
+					  log->fd, log->listen_fd, log->default_prefix);
+			}
+		}
 	}
 }
 


More information about the dovecot-cvs mailing list