From: Timo Sirainen Date: Fri, 24 Mar 2023 00:29:39 +0000 (+0200) Subject: imap: Update process title while unhibernating X-Git-Tag: 2.3.21~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af6edaef3fb788c934a94ff5a1f1ddd2ab151fd9;p=thirdparty%2Fdovecot%2Fcore.git imap: Update process title while unhibernating 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. --- diff --git a/src/imap/imap-master-client.c b/src/imap/imap-master-client.c index eae18e323c..84814f01c5 100644 --- a/src/imap/imap-master-client.c +++ b/src/imap/imap-master-client.c @@ -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); diff --git a/src/imap/imap-master-client.h b/src/imap/imap-master-client.h index 478a64a474..ef66ab9445 100644 --- a/src/imap/imap-master-client.h +++ b/src/imap/imap-master-client.h @@ -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); diff --git a/src/imap/main.c b/src/imap/main.c index be4fd62aa8..5fa540ade4 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -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)