]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master, global: Add and use MASTER_SERVICE_SHUTTING_DOWN_MSG
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 8 Feb 2022 14:33:31 +0000 (15:33 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 21 Feb 2022 06:30:26 +0000 (06:30 +0000)
Use a macro to replace "Server shutting down" texts in different services.

src/doveadm/client-connection-http.c
src/imap-hibernate/imap-client.c
src/imap-urlauth/imap-urlauth-client.c
src/imap/imap-client.c
src/imap/main.c
src/lib-http/http-server-connection.c
src/lib-master/master-service.h
src/pop3/pop3-client.c
src/submission/submission-client.c

index cb499ef91f5c670ab2b353a5f4672b72d6745b8a..92075efdfe6645d5930949b4529717ae709d3be7 100644 (file)
@@ -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);
        }
 }
 
index bddf81ff510512dd394e730c2a5073ae9f87cf14..55ffd528d0062ace02ce83c5b33bdc0bb1e32b59 100644 (file)
@@ -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)
index 0dbb682e352b71a755bbd683b977cfeb7320e6fe..d3f4ebc5490f63671b2442f395be124ac22434b6 100644 (file)
@@ -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);
+       }
 }
index 45140d5d8959338eca012021ea3390920a70e90f..1ae80b2728996faf767a29195a974f6e8d7b79af 100644 (file)
@@ -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)
index 6d6b6234bd925071e48a638d7392ac26f8ec9cd6..0bbed8a4238e4343bea645ba22b83ddfc3e86f4b 100644 (file)
@@ -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)
index 801a7037f1061f2f46ccc071e8f4413112be92a3..ae9f20ae6af823cf2511bd7619718803750cb0b0 100644 (file)
@@ -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;
index 49317cbe019256911297f2c0291a377057e3dead..c468997ca45a5b7886619fbe10dab4a6a7972306 100644 (file)
@@ -7,6 +7,8 @@
 #include <unistd.h> /* for getopt() opt* variables */
 #include <stdio.h> /* 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,
index b6c151addb0381539daad57dbe35d7c2f671517c..909a923478f26aaf036adb69f5e523d338c2ed59 100644 (file)
@@ -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)
index ab68185d88545e8aacb27bfc5671287cb35ceecd..a07a5e31540c594f0e00868e0fea20536f145a4e 100644 (file)
@@ -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)