dovecot-2.2: director: Log a warning if directors' clocks are to...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 12 12:59:21 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/d96595e2363b
changeset: 19294:d96595e2363b
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 12 15:57:42 2015 +0300
description:
director: Log a warning if directors' clocks are too much out of sync.

diffstat:

 src/director/director-connection.c |  22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diffs (47 lines):

diff -r 8f225e43e6e3 -r d96595e2363b src/director/director-connection.c
--- a/src/director/director-connection.c	Mon Oct 12 15:47:46 2015 +0300
+++ b/src/director/director-connection.c	Mon Oct 12 15:57:42 2015 +0300
@@ -78,6 +78,7 @@
    valid received SYNC timestamp, assume that we lost the director's restart
    notification and reset the last_sync_seq */
 #define DIRECTOR_SYNC_STALE_TIMESTAMP_RESET_SECS (60*2)
+#define DIRECTOR_MAX_CLOCK_DIFF_WARN_SECS 1
 
 #if DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS <= DIRECTOR_CONNECTION_PING_TIMEOUT_MSECS
 #  error DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS is too low
@@ -388,6 +389,22 @@
 	}
 	conn->me_received = TRUE;
 
+	if (args[2] != NULL) {
+		time_t remote_time;
+		int diff;
+
+		if (str_to_time(args[2], &remote_time) < 0) {
+			director_cmd_error(conn, "Invalid ME timestamp");
+			return FALSE;
+		}
+		diff = ioloop_time - remote_time;
+		if (diff > DIRECTOR_MAX_CLOCK_DIFF_WARN_SECS ||
+		    (diff < 0 && -diff > DIRECTOR_MAX_CLOCK_DIFF_WARN_SECS)) {
+			i_warning("Director %s clock differs from ours by %d secs",
+				  conn->name, diff);
+		}
+	}
+
 	timeout_remove(&conn->to_ping);
 	conn->to_ping = timeout_add(DIRECTOR_CONNECTION_DONE_TIMEOUT_MSECS,
 				    director_connection_init_timeout, conn);
@@ -1799,9 +1816,10 @@
 {
 	director_connection_send(conn, t_strdup_printf(
 		"VERSION\t"DIRECTOR_VERSION_NAME"\t%u\t%u\n"
-		"ME\t%s\t%u\n",
+		"ME\t%s\t%u\t%lld\n",
 		DIRECTOR_VERSION_MAJOR, DIRECTOR_VERSION_MINOR,
-		net_ip2addr(&conn->dir->self_ip), conn->dir->self_port));
+		net_ip2addr(&conn->dir->self_ip), conn->dir->self_port,
+		(long long)time(NULL)));
 }
 
 struct director_connection *


More information about the dovecot-cvs mailing list