dovecot-2.1: anvil: Handle crash restarts without failing comple...

dovecot at dovecot.org dovecot at dovecot.org
Fri Nov 4 20:01:17 EET 2011


details:   http://hg.dovecot.org/dovecot-2.1/rev/926a7ceeaa10
changeset: 13648:926a7ceeaa10
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 04 20:11:39 2011 +0200
description:
anvil: Handle crash restarts without failing completely.

diffstat:

 src/anvil/anvil-connection.c |  7 ++++++-
 src/anvil/common.h           |  1 +
 src/anvil/main.c             |  3 +++
 src/master/service-anvil.c   |  1 +
 src/master/service-anvil.h   |  2 ++
 src/master/service-process.c |  4 ++++
 6 files changed, 17 insertions(+), 1 deletions(-)

diffs (89 lines):

diff -r 9f739df97593 -r 926a7ceeaa10 src/anvil/anvil-connection.c
--- a/src/anvil/anvil-connection.c	Fri Nov 04 19:52:26 2011 +0200
+++ b/src/anvil/anvil-connection.c	Fri Nov 04 20:11:39 2011 +0200
@@ -150,8 +150,13 @@
 
 		if (!version_string_verify(line, "anvil",
 				ANVIL_CLIENT_PROTOCOL_MAJOR_VERSION)) {
+			if (anvil_restarted && (conn->master || conn->fifo)) {
+				/* old pending data. ignore input until we get
+				   the handshake. */
+				return anvil_connection_input(context);
+			}
 			i_error("Anvil client not compatible with this server "
-				"(mixed old and new binaries?)");
+				"(mixed old and new binaries?) %s", line);
 			anvil_connection_destroy(conn);
 			return;
 		}
diff -r 9f739df97593 -r 926a7ceeaa10 src/anvil/common.h
--- a/src/anvil/common.h	Fri Nov 04 19:52:26 2011 +0200
+++ b/src/anvil/common.h	Fri Nov 04 20:11:39 2011 +0200
@@ -5,5 +5,6 @@
 
 extern struct connect_limit *connect_limit;
 extern struct penalty *penalty;
+extern bool anvil_restarted;
 
 #endif
diff -r 9f739df97593 -r 926a7ceeaa10 src/anvil/main.c
--- a/src/anvil/main.c	Fri Nov 04 19:52:26 2011 +0200
+++ b/src/anvil/main.c	Fri Nov 04 20:11:39 2011 +0200
@@ -13,10 +13,12 @@
 #include "penalty.h"
 #include "anvil-connection.h"
 
+#include <stdlib.h>
 #include <unistd.h>
 
 struct connect_limit *connect_limit;
 struct penalty *penalty;
+bool anvil_restarted;
 static struct io *log_fdpass_io;
 
 static void client_connected(struct master_service_connection *conn)
@@ -65,6 +67,7 @@
 
 	restrict_access_by_env(NULL, FALSE);
 	restrict_access_allow_coredumps(TRUE);
+	anvil_restarted = getenv("ANVIL_RESTARTED") != NULL;
 
 	/* delay dying until all of our clients are gone */
 	master_service_set_die_with_master(master_service, FALSE);
diff -r 9f739df97593 -r 926a7ceeaa10 src/master/service-anvil.c
--- a/src/master/service-anvil.c	Fri Nov 04 19:52:26 2011 +0200
+++ b/src/master/service-anvil.c	Fri Nov 04 20:11:39 2011 +0200
@@ -125,6 +125,7 @@
 
 	if (service_anvil_global->pid == process->pid)
 		service_anvil_global->pid = 0;
+	service_anvil_global->restarted = TRUE;
 }
 
 void service_anvil_send_log_fd(void)
diff -r 9f739df97593 -r 926a7ceeaa10 src/master/service-anvil.h
--- a/src/master/service-anvil.h	Fri Nov 04 19:52:26 2011 +0200
+++ b/src/master/service-anvil.h	Fri Nov 04 20:11:39 2011 +0200
@@ -17,6 +17,8 @@
 	struct io *io_blocking, *io_nonblocking;
 
 	unsigned int process_count;
+	/* anvil crashed and we're now restarting it */
+	bool restarted;
 };
 
 extern struct service_anvil_global *service_anvil_global;
diff -r 9f739df97593 -r 926a7ceeaa10 src/master/service-process.c
--- a/src/master/service-process.c	Fri Nov 04 19:52:26 2011 +0200
+++ b/src/master/service-process.c	Fri Nov 04 20:11:39 2011 +0200
@@ -188,6 +188,10 @@
 	master_service_env_clean();
 
 	switch (service->type) {
+	case SERVICE_TYPE_ANVIL:
+		if (service_anvil_global->restarted)
+			env_put("ANVIL_RESTARTED=1");
+		break;
 	case SERVICE_TYPE_CONFIG:
 		env_put(t_strconcat(MASTER_CONFIG_FILE_ENV"=",
 				    service->config_file_path, NULL));


More information about the dovecot-cvs mailing list