dovecot-2.2: log: If too much logging data is sent, show it in p...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 9 02:03:26 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/8f7dee2e7e05
changeset: 18232:8f7dee2e7e05
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 09 04:03:12 2015 +0200
description:
log: If too much logging data is sent, show it in process title.

diffstat:

 src/log/log-connection.c     |  55 ++++++++++++++++++++++++++++++++++++++-----
 src/log/log-connection.h     |   2 +
 src/log/main.c               |   3 ++
 src/master/service-process.c |   2 +
 4 files changed, 55 insertions(+), 7 deletions(-)

diffs (127 lines):

diff -r dec13d8f524c -r 8f7dee2e7e05 src/log/log-connection.c
--- a/src/log/log-connection.c	Sat Feb 07 18:39:05 2015 +0200
+++ b/src/log/log-connection.c	Mon Feb 09 04:03:12 2015 +0200
@@ -7,6 +7,7 @@
 #include "llist.h"
 #include "hash.h"
 #include "time-util.h"
+#include "process-title.h"
 #include "master-interface.h"
 #include "master-service.h"
 #include "log-error-buffer.h"
@@ -51,9 +52,37 @@
 
 static struct log_connection *log_connections = NULL;
 static ARRAY(struct log_connection *) logs_by_fd;
+static unsigned int global_pending_count;
+static struct log_connection *last_pending_log;
 
 static void log_connection_destroy(struct log_connection *log);
 
+static void log_refresh_proctitle(void)
+{
+	if (!verbose_proctitle)
+		return;
+
+	if (global_pending_count == 0)
+		process_title_set("");
+	else if (last_pending_log == NULL) {
+		process_title_set(t_strdup_printf(
+			"[%u services too fast]", global_pending_count));
+	} else if (global_pending_count > 1) {
+		process_title_set(t_strdup_printf(
+			"[%u services too fast, last: %d/%d/%s]",
+			global_pending_count,
+			last_pending_log->fd,
+			last_pending_log->listen_fd,
+			last_pending_log->default_prefix));
+	} else {
+		process_title_set(t_strdup_printf(
+			"[service too fast: %d/%d/%s]",
+			last_pending_log->fd,
+			last_pending_log->listen_fd,
+			last_pending_log->default_prefix));
+	}
+}
+
 static struct log_client *log_client_get(struct log_connection *log, pid_t pid)
 {
 	struct log_client *client;
@@ -326,14 +355,26 @@
 		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);
+		if (ret == 0) {
+			if (log->pending_count > 0) {
+				log->pending_count = 0;
+				i_assert(global_pending_count > 0);
+				global_pending_count--;
+				if (log == last_pending_log)
+					last_pending_log = NULL;
+				log_refresh_proctitle();
 			}
+			return;
+		}
+		last_pending_log = log;
+		if (log->pending_count++ == 0) {
+			global_pending_count++;
+			log_refresh_proctitle();
+		}
+		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);
 		}
 	}
 }
diff -r dec13d8f524c -r 8f7dee2e7e05 src/log/log-connection.h
--- a/src/log/log-connection.h	Sat Feb 07 18:39:05 2015 +0200
+++ b/src/log/log-connection.h	Mon Feb 09 04:03:12 2015 +0200
@@ -3,6 +3,8 @@
 
 struct log_connection;
 
+extern bool verbose_proctitle;
+
 void log_connection_create(struct log_error_buffer *errorbuf,
 			   int fd, int listen_fd);
 
diff -r dec13d8f524c -r 8f7dee2e7e05 src/log/main.c
--- a/src/log/main.c	Sat Feb 07 18:39:05 2015 +0200
+++ b/src/log/main.c	Mon Feb 09 04:03:12 2015 +0200
@@ -12,6 +12,7 @@
 
 #include <unistd.h>
 
+bool verbose_proctitle;
 static struct log_error_buffer *errorbuf;
 
 static void
@@ -71,6 +72,8 @@
 		i_fatal("Error reading configuration: %s", error);
 	master_service_init_log(master_service, "log: ");
 
+	verbose_proctitle = master_service_settings_get(master_service)->verbose_proctitle;
+
 	restrict_access_by_env(NULL, FALSE);
 	restrict_access_allow_coredumps(TRUE);
 
diff -r dec13d8f524c -r 8f7dee2e7e05 src/master/service-process.c
--- a/src/master/service-process.c	Sat Feb 07 18:39:05 2015 +0200
+++ b/src/master/service-process.c	Mon Feb 09 04:03:12 2015 +0200
@@ -227,6 +227,8 @@
 		env_put(t_strconcat("DEBUG_LOG_PATH=", set->debug_log_path, NULL));
 		env_put(t_strconcat("LOG_TIMESTAMP=", set->log_timestamp, NULL));
 		env_put(t_strconcat("SYSLOG_FACILITY=", set->syslog_facility, NULL));
+		if (set->verbose_proctitle)
+			env_put("VERBOSE_PROCTITLE=1");
 		env_put("SSL=no");
 		break;
 	default:


More information about the dovecot-cvs mailing list