]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lmtp: client: Restructured client_state_set() to match imap_refresh_proctitle().
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 10 Oct 2017 00:36:34 +0000 (02:36 +0200)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Thu, 7 Dec 2017 23:08:14 +0000 (00:08 +0100)
src/lmtp/client.c

index c4c86bd51e17374aca64c437b0a1c743c03a898d..ef7dfaedefba1d1446698c17110190148917017c 100644 (file)
@@ -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)