From: Timo Sirainen Date: Thu, 29 Oct 2020 11:35:35 +0000 (+0200) Subject: imap: Process title wrongly shows connections are "corked" X-Git-Tag: 2.3.14.rc1~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfb013491a7046237222c0dd3550a2e1f184ed7a;p=thirdparty%2Fdovecot%2Fcore.git imap: Process title wrongly shows connections are "corked" The flush callback in ostream-file always corks the connection, so the process title needs to be delayed until it's no longer in that callback. Add a 0-timeout to update the process title. --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 2c7681d6d6..07b2a8018b 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -1433,7 +1433,7 @@ int client_output(struct client *client) client_output_commands(client); (void)cmd_sync_delayed(client); - imap_refresh_proctitle(); + imap_refresh_proctitle_delayed(); if (client->output->closed) client_destroy(client, NULL); else { diff --git a/src/imap/imap-common.h b/src/imap/imap-common.h index 1e214eb5c4..1609a8b5ba 100644 --- a/src/imap/imap-common.h +++ b/src/imap/imap-common.h @@ -31,6 +31,7 @@ imap_client_created_func_t * ATTR_NOWARN_UNUSED_RESULT imap_client_created_hook_set(imap_client_created_func_t *new_hook); void imap_refresh_proctitle(void); +void imap_refresh_proctitle_delayed(void); int client_create_from_input(const struct mail_storage_service_input *input, int fd_in, int fd_out, struct client **client_r, diff --git a/src/imap/main.c b/src/imap/main.c index 90a4cf1d29..747b7eb8d7 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -35,6 +35,7 @@ static bool verbose_proctitle = FALSE; static struct mail_storage_service_ctx *storage_service; static struct master_login *master_login = NULL; +static struct timeout *to_proctitle; imap_client_created_func_t *hook_client_created = NULL; bool imap_debug = FALSE; @@ -52,6 +53,19 @@ imap_client_created_hook_set(imap_client_created_func_t *new_hook) return old_hook; } +static void imap_refresh_proctitle_callback(void *context ATTR_UNUSED) +{ + timeout_remove(&to_proctitle); + imap_refresh_proctitle(); +} + +void imap_refresh_proctitle_delayed(void) +{ + if (to_proctitle == NULL) + to_proctitle = timeout_add_short(0, + imap_refresh_proctitle_callback, NULL); +} + void imap_refresh_proctitle(void) { #define IMAP_PROCTITLE_PREFERRED_LEN 80 @@ -542,6 +556,7 @@ int main(int argc, char *argv[]) commands_deinit(); imap_master_clients_deinit(); + timeout_remove(&to_proctitle); master_service_deinit(&master_service); return 0; }