diff src/pop3/main.c @ 10171:7f0ccd367351 HEAD

Handle shutdown_clients globally for all services. Delay shutting down processes until it's convenient for them, but if they're not gone in 30 seconds forcibly stop. And if that doesn't help, master will start killing them in 60 seconds.
author Timo Sirainen <tss@iki.fi>
date Fri, 23 Oct 2009 16:22:53 -0400
parents ff200b8e4929
children 02e852b2c2c3
line wrap: on
line diff
--- a/src/pop3/main.c	Fri Oct 23 16:19:34 2009 -0400
+++ b/src/pop3/main.c	Fri Oct 23 16:22:53 2009 -0400
@@ -25,6 +25,11 @@
 
 void (*hook_client_created)(struct client **client) = NULL;
 
+static void pop3_die(void)
+{
+	/* do nothing. pop3 connections typically die pretty quick anyway. */
+}
+
 static void client_add_input(struct client *client, const buffer_t *buf)
 {
 	struct ostream *output;
@@ -57,12 +62,9 @@
 	if (mail_storage_service_lookup_next(storage_service, input,
 					     &user, &mail_user, error_r) <= 0)
 		return -1;
-	set = mail_storage_service_user_get_set(user)[1];
+	restrict_access_allow_coredumps(TRUE);
 
-	restrict_access_allow_coredumps(TRUE);
-	if (set->shutdown_clients)
-		master_service_set_die_with_master(master_service, TRUE);
-
+	set = mail_storage_service_user_get_set(user)[1];
 	client = client_create(fd_in, fd_out, mail_user, user, set);
 	T_BEGIN {
 		client_add_input(client, input_buf);
@@ -166,6 +168,7 @@
 	if (master_getopt(master_service) > 0)
 		return FATAL_DEFAULT;
 	master_service_init_finish(master_service);
+	master_service_set_die_callback(master_service, pop3_die);
 
 	storage_service =
 		mail_storage_service_init(master_service,