]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-master: Added MASTER_SERVICE_FLAG_UPDATE_PROCTITLE for showing number of connecti...
authorTimo Sirainen <tss@iki.fi>
Wed, 3 Nov 2010 15:23:52 +0000 (15:23 +0000)
committerTimo Sirainen <tss@iki.fi>
Wed, 3 Nov 2010 15:23:52 +0000 (15:23 +0000)
The title is still only updated if verbose_proctitle=yes, so this allows
binaries to easily just set the flag and lib-master handles the rest.

src/lib-master/master-service-settings.c
src/lib-master/master-service-settings.h
src/lib-master/master-service.c
src/lib-master/master-service.h

index 78bed7abdb40ac5a5bcd322b95108d680a48a521..526c032d4c68e6ce6dea1514588f4a6e38a639f2 100644 (file)
@@ -41,6 +41,7 @@ static const struct setting_define master_service_setting_defines[] = {
        DEF(SET_SIZE, config_cache_size),
        DEF(SET_BOOL, version_ignore),
        DEF(SET_BOOL, shutdown_clients),
+       DEF(SET_BOOL, verbose_proctitle),
 
        SETTING_DEFINE_LIST_END
 };
@@ -53,7 +54,8 @@ static const struct master_service_settings master_service_default_settings = {
        .syslog_facility = "mail",
        .config_cache_size = 1024*1024,
        .version_ignore = FALSE,
-       .shutdown_clients = TRUE
+       .shutdown_clients = TRUE,
+       .verbose_proctitle = FALSE
 };
 
 const struct setting_parser_info master_service_setting_parser_info = {
index 064e914a2e53e9a4013cb882918731d0efadf805..ae29c48ff946de9ae1a71f7238048c0cfd4ca62c 100644 (file)
@@ -15,6 +15,7 @@ struct master_service_settings {
        uoff_t config_cache_size;
        bool version_ignore;
        bool shutdown_clients;
+       bool verbose_proctitle;
 };
 
 struct master_service_settings_input {
index 5724b7b43cba16c6fe0fe42ca5fa88f601f42d9a..e2dc98d583bde03bf423639c38b065c6bd204a12 100644 (file)
@@ -827,6 +827,15 @@ void master_status_update(struct master_service *service)
        ssize_t ret;
        bool important_update;
 
+       if ((service->flags & MASTER_SERVICE_FLAG_UPDATE_PROCTITLE) != 0 &&
+           service->set != NULL && service->set->verbose_proctitle) T_BEGIN {
+               unsigned int used_count = service->total_available_count -
+                       service->master_status.available_count;
+
+               process_title_set(t_strdup_printf("[%u connections]",
+                                                 used_count));
+       } T_END;
+
        important_update = master_status_update_is_important(service);
        if (service->master_status.pid == 0 ||
            service->master_status.available_count ==
index 8308450493fa88b3f3b069b7e6e969ec26faafe1..95346b6a81cfd5c6c001bb8f78b758560bbe52f0 100644 (file)
@@ -19,7 +19,10 @@ enum master_service_flags {
        /* Use MASTER_LOGIN_NOTIFY_FD to track login overflow state */
        MASTER_SERVICE_FLAG_TRACK_LOGIN_STATE   = 0x40,
        /* If master sends SIGINT, don't die even if we don't have clients */
-       MASTER_SERVICE_FLAG_NO_IDLE_DIE         = 0x80
+       MASTER_SERVICE_FLAG_NO_IDLE_DIE         = 0x80,
+       /* Show number of connections in process title
+          (only if verbose_proctitle setting is enabled) */
+       MASTER_SERVICE_FLAG_UPDATE_PROCTITLE    = 0x100
 };
 
 struct master_service_connection {