]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Update process title while unhibernating
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 24 Mar 2023 00:29:39 +0000 (02:29 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Sun, 14 May 2023 17:52:36 +0000 (17:52 +0000)
Previously the process title stayed as [idling] even though the process was
busy waiting on the imap-hibernate process to finish sending the
unhibernation request.

src/imap/imap-master-client.c
src/imap/imap-master-client.h
src/imap/main.c

index eae18e323ce35a04e51524c68704ec6ede92a1dd..84814f01c5188a90d625962eb1eaae43c0d9f821 100644 (file)
@@ -10,6 +10,7 @@
 #include "strescape.h"
 #include "str-sanitize.h"
 #include "time-util.h"
+#include "process-title.h"
 #include "master-service.h"
 #include "mail-storage-service.h"
 #include "imap-client.h"
@@ -236,6 +237,7 @@ imap_master_client_input_args(struct connection *conn, const char *const *args,
                i_close_fd(&fd_client);
                return -1;
        }
+       process_title_set("[unhibernating]");
 
        /* NOTE: before client_create_from_input() on failures we need to close
           fd_client, but afterward it gets closed by client_destroy() */
@@ -396,6 +398,8 @@ void imap_master_client_create(int fd)
 
        /* read the first file descriptor that we can */
        i_stream_unix_set_read_fd(client->conn.input);
+
+       imap_refresh_proctitle();
 }
 
 static struct connection_settings client_set = {
@@ -418,6 +422,21 @@ static const struct connection_vfuncs client_vfuncs = {
        .idle_timeout = imap_master_client_idle_timeout,
 };
 
+bool imap_master_clients_refresh_proctitle(void)
+{
+       switch (master_clients->connections_count) {
+       case 0:
+               return FALSE;
+       case 1:
+               process_title_set("[waiting on unhibernate client]");
+               return TRUE;
+       default:
+               process_title_set(t_strdup_printf("[unhibernating %u clients]",
+                       master_clients->connections_count));
+               return TRUE;
+       }
+}
+
 void imap_master_clients_init(void)
 {
        master_clients = connection_list_init(&client_set, &client_vfuncs);
index 478a64a474cec880dc6211ac78d88c9c271ae985..ef66ab944570d2547831e4e01fe651b461263d78 100644 (file)
@@ -2,6 +2,7 @@
 #define IMAP_MASTER_CLIENT_H
 
 void imap_master_client_create(int fd);
+bool imap_master_clients_refresh_proctitle(void);
 
 void imap_master_clients_init(void);
 void imap_master_clients_deinit(void);
index be4fd62aa8e7a17bd66dac0d4debe109e57a6bdd..5fa540ade42bc854c30eca78b2cb26a6abbb5485 100644 (file)
@@ -71,12 +71,16 @@ void imap_refresh_proctitle(void)
 #define IMAP_PROCTITLE_PREFERRED_LEN 80
        struct client *client;
        struct client_command_context *cmd;
-       string_t *title = t_str_new(128);
        bool wait_output;
 
        if (!verbose_proctitle)
                return;
+       if (imap_client_count == 0) {
+               if (imap_master_clients_refresh_proctitle())
+                       return;
+       }
 
+       string_t *title = t_str_new(128);
        str_append_c(title, '[');
        switch (imap_client_count) {
        case 0:
@@ -528,6 +532,9 @@ int main(int argc, char *argv[])
        imap_features_init();
        clients_init();
        imap_master_clients_init();
+       /* this is needed before settings are read */
+       verbose_proctitle = !IS_STANDALONE() &&
+               getenv(MASTER_VERBOSE_PROCTITLE_ENV) != NULL;
 
        const char *error;
        if (t_abspath(auth_socket_path, &login_set.auth_socket_path, &error) < 0)