From 8590275ece826d76c38dccf84215ec86b205e1b5 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 8 Mar 2017 15:39:34 -0500 Subject: [PATCH] imap, pop3, indexer-worker: Add (deinit) to process title before autoexpunging runs. lmtp should also do this, but it needs a bit larger changes. --- src/imap/imap-client.c | 2 ++ src/imap/main.c | 2 ++ src/indexer/master-connection.c | 5 ++++- src/pop3/main.c | 2 ++ src/pop3/pop3-client.c | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 1158253b61..c16bf8c02e 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -453,6 +453,8 @@ static void client_default_destroy(struct client *client, const char *reason) /* i/ostreams are already closed at this stage, so fd can be closed */ fd_close_maybe_stdio(&client->fd_in, &client->fd_out); + /* refresh proctitle before a potentially long-running user unref */ + imap_refresh_proctitle(); /* Free the user after client is already disconnected. It may start some background work like autoexpunging. */ mail_user_unref(&client->user); diff --git a/src/imap/main.c b/src/imap/main.c index 050692eebd..fd9fd1950f 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -88,6 +88,8 @@ void imap_refresh_proctitle(void) if (o_stream_is_corked(client->output)) str_append(title, " corked"); } + if (client->destroyed) + str_append(title, " (deinit)"); break; default: str_printfa(title, "%u connections", imap_client_count); diff --git a/src/indexer/master-connection.c b/src/indexer/master-connection.c index aab4def2f1..2033823610 100644 --- a/src/indexer/master-connection.c +++ b/src/indexer/master-connection.c @@ -227,9 +227,12 @@ master_connection_input_line(struct master_connection *conn, const char *line) indexer_worker_refresh_proctitle(user->username, args[1], 0, 0); ret = index_mailbox(conn, user, args[1], max_recent_msgs, args[4]); - indexer_worker_refresh_proctitle(NULL, NULL, 0, 0); + /* refresh proctitle before a potentially long-running + user unref */ + indexer_worker_refresh_proctitle(user->username, "(deinit)", 0, 0); mail_user_unref(&user); mail_storage_service_user_unref(&service_user); + indexer_worker_refresh_proctitle(NULL, NULL, 0, 0); } str = ret < 0 ? "-1\n" : "100\n"; diff --git a/src/pop3/main.c b/src/pop3/main.c index 54bbc15eea..685eeb011c 100644 --- a/src/pop3/main.c +++ b/src/pop3/main.c @@ -59,6 +59,8 @@ void pop3_refresh_proctitle(void) str_append_c(title, ' '); str_append(title, net_ip2addr(client->user->remote_ip)); } + if (client->destroyed) + str_append(title, " (deinit)"); break; default: str_printfa(title, "%u connections", pop3_client_count); diff --git a/src/pop3/pop3-client.c b/src/pop3/pop3-client.c index 0036122b4c..ce3a288bb9 100644 --- a/src/pop3/pop3-client.c +++ b/src/pop3/pop3-client.c @@ -624,6 +624,9 @@ static void client_default_destroy(struct client *client, const char *reason) mail_user_get_anvil_userip_ident(client->user), "\n", NULL)); } + + /* refresh proctitle before a potentially long-running user unref */ + pop3_refresh_proctitle(); mail_user_unref(&client->user); if (client->session_dotlock != NULL) -- 2.47.3