From: Stephan Bosch Date: Tue, 10 Oct 2017 00:36:34 +0000 (+0200) Subject: lmtp: client: Restructured client_state_set() to match imap_refresh_proctitle(). X-Git-Tag: 2.3.0.rc1~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=942b4f4548a0f45cfe34709ea8a1465b43cb4707;p=thirdparty%2Fdovecot%2Fcore.git lmtp: client: Restructured client_state_set() to match imap_refresh_proctitle(). --- diff --git a/src/lmtp/client.c b/src/lmtp/client.c index c4c86bd51e..ef7dfaedef 100644 --- a/src/lmtp/client.c +++ b/src/lmtp/client.c @@ -40,30 +40,32 @@ static bool verbose_proctitle = FALSE; void client_state_set(struct client *client, const char *name, const char *args) { - string_t *str; + string_t *title; client->state.name = name; if (!verbose_proctitle) return; - if (clients_count == 0) { - process_title_set("[idling]"); - return; - } - if (clients_count > 1) { - process_title_set(t_strdup_printf("[%u clients]", clients_count)); - return; + title = t_str_new(128); + str_append_c(title, '['); + switch (clients_count) { + case 0: + str_append(title, "idling"); + break; + case 1: + str_append(title, client->state.name); + if (client->remote_ip.family != 0) + str_printfa(title, " %s", net_ip2addr(&client->remote_ip)); + if (args[0] != '\0') + str_printfa(title, " %s", args); + break; + default: + str_printfa(title, "%u connections", clients_count); + break; } - - str = t_str_new(128); - str_printfa(str, "[%s", client->state.name); - if (client->remote_ip.family != 0) - str_printfa(str, " %s", net_ip2addr(&client->remote_ip)); - if (args[0] != '\0') - str_printfa(str, " %s", args); - str_append_c(str, ']'); - process_title_set(str_c(str)); + str_append_c(title, ']'); + process_title_set(str_c(title)); } static void client_idle_timeout(struct client *client)