From: Timo Sirainen Date: Tue, 8 Feb 2022 14:33:31 +0000 (+0100) Subject: lib-master, global: Add and use MASTER_SERVICE_SHUTTING_DOWN_MSG X-Git-Tag: 2.4.0~4395 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cf72e57ffe0003a22bc2bd18be113860c4ffbc7;p=thirdparty%2Fdovecot%2Fcore.git lib-master, global: Add and use MASTER_SERVICE_SHUTTING_DOWN_MSG Use a macro to replace "Server shutting down" texts in different services. --- diff --git a/src/doveadm/client-connection-http.c b/src/doveadm/client-connection-http.c index cb499ef91f..92075efdfe 100644 --- a/src/doveadm/client-connection-http.c +++ b/src/doveadm/client-connection-http.c @@ -1162,7 +1162,7 @@ client_connection_http_free(struct client_connection *_conn) /* We're not in the lib-http/server's connection destroy callback. */ http_server_connection_close(&conn->http_conn, - "Server shutting down"); + MASTER_SERVICE_SHUTTING_DOWN_MSG); } } diff --git a/src/imap-hibernate/imap-client.c b/src/imap-hibernate/imap-client.c index bddf81ff51..55ffd528d0 100644 --- a/src/imap-hibernate/imap-client.c +++ b/src/imap-hibernate/imap-client.c @@ -782,8 +782,9 @@ static void imap_clients_unhibernate(void *context ATTR_UNUSED) static void imap_client_kick(struct imap_client *client) { imap_client_io_activate_user(client); - o_stream_nsend_str(client->output, "* BYE Server shutting down.\r\n"); - imap_client_destroy(&client, "Server shutting down"); + o_stream_nsend_str(client->output, + "* BYE "MASTER_SERVICE_SHUTTING_DOWN_MSG".\r\n"); + imap_client_destroy(&client, MASTER_SERVICE_SHUTTING_DOWN_MSG); } void imap_clients_init(void) diff --git a/src/imap-urlauth/imap-urlauth-client.c b/src/imap-urlauth/imap-urlauth-client.c index 0dbb682e35..d3f4ebc549 100644 --- a/src/imap-urlauth/imap-urlauth-client.c +++ b/src/imap-urlauth/imap-urlauth-client.c @@ -375,6 +375,8 @@ void client_disconnect(struct client *client, const char *reason) void clients_destroy_all(void) { - while (imap_urlauth_clients != NULL) - client_destroy(imap_urlauth_clients, "Server shutting down"); + while (imap_urlauth_clients != NULL) { + client_destroy(imap_urlauth_clients, + MASTER_SERVICE_SHUTTING_DOWN_MSG); + } } diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 45140d5d89..1ae80b2728 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -1657,9 +1657,11 @@ void clients_init(void) void client_kick(struct client *client) { mail_storage_service_io_activate_user(client->service_user); - if (client->output_cmd_lock == NULL) - client_send_line(client, "* BYE Server shutting down."); - client_destroy(client, "Server shutting down"); + if (client->output_cmd_lock == NULL) { + client_send_line(client, + "* BYE "MASTER_SERVICE_SHUTTING_DOWN_MSG"."); + } + client_destroy(client, MASTER_SERVICE_SHUTTING_DOWN_MSG); } void clients_destroy_all(void) diff --git a/src/imap/main.c b/src/imap/main.c index 6d6b6234bd..0bbed8a423 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -126,8 +126,8 @@ static void client_kill_idle(struct client *client) return; mail_storage_service_io_activate_user(client->service_user); - client_send_line(client, "* BYE Server shutting down."); - client_destroy(client, "Server shutting down"); + client_send_line(client, "* BYE "MASTER_SERVICE_SHUTTING_DOWN_MSG"."); + client_destroy(client, MASTER_SERVICE_SHUTTING_DOWN_MSG); } static void imap_die(void) diff --git a/src/lib-http/http-server-connection.c b/src/lib-http/http-server-connection.c index 801a7037f1..ae9f20ae6a 100644 --- a/src/lib-http/http-server-connection.c +++ b/src/lib-http/http-server-connection.c @@ -140,7 +140,8 @@ bool http_server_connection_shut_down(struct http_server_connection *conn) { if (conn->request_queue_head == NULL || conn->request_queue_head->state == HTTP_SERVER_REQUEST_STATE_NEW) { - http_server_connection_close(&conn, "Server shutting down"); + http_server_connection_close(&conn, + MASTER_SERVICE_SHUTTING_DOWN_MSG); return TRUE; } return FALSE; diff --git a/src/lib-master/master-service.h b/src/lib-master/master-service.h index 49317cbe01..c468997ca4 100644 --- a/src/lib-master/master-service.h +++ b/src/lib-master/master-service.h @@ -7,6 +7,8 @@ #include /* for getopt() opt* variables */ #include /* for getopt() opt* variables in Solaris */ +#define MASTER_SERVICE_SHUTTING_DOWN_MSG "Server shutting down" + enum master_service_flags { /* stdin/stdout already contains a client which we want to serve */ MASTER_SERVICE_FLAG_STD_CLIENT = 0x01, diff --git a/src/pop3/pop3-client.c b/src/pop3/pop3-client.c index b6c151addb..909a923478 100644 --- a/src/pop3/pop3-client.c +++ b/src/pop3/pop3-client.c @@ -853,9 +853,9 @@ void client_kick(struct client *client) mail_storage_service_io_activate_user(client->service_user); if (client->cmd == NULL) { client_send_line(client, - "-ERR [SYS/TEMP] Server shutting down."); + "-ERR [SYS/TEMP] "MASTER_SERVICE_SHUTTING_DOWN_MSG"."); } - client_destroy(client, "Server shutting down"); + client_destroy(client, MASTER_SERVICE_SHUTTING_DOWN_MSG); } void clients_destroy_all(void) diff --git a/src/submission/submission-client.c b/src/submission/submission-client.c index ab68185d88..a07a5e3154 100644 --- a/src/submission/submission-client.c +++ b/src/submission/submission-client.c @@ -496,7 +496,7 @@ void client_add_extra_capability(struct client *client, const char *capability, void client_kick(struct client *client) { mail_storage_service_io_activate_user(client->service_user); - client_destroy(&client, "4.3.2", "Server shutting down"); + client_destroy(&client, "4.3.2", MASTER_SERVICE_SHUTTING_DOWN_MSG); } void clients_destroy_all(void)