From: Timo Sirainen Date: Wed, 3 Nov 2010 15:23:52 +0000 (+0000) Subject: lib-master: Added MASTER_SERVICE_FLAG_UPDATE_PROCTITLE for showing number of connecti... X-Git-Tag: 2.0.7~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2bdca8201e4aa1cd31332ffbdd4c6eef9151d5e;p=thirdparty%2Fdovecot%2Fcore.git lib-master: Added MASTER_SERVICE_FLAG_UPDATE_PROCTITLE for showing number of connections in ps. 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. --- diff --git a/src/lib-master/master-service-settings.c b/src/lib-master/master-service-settings.c index 78bed7abdb..526c032d4c 100644 --- a/src/lib-master/master-service-settings.c +++ b/src/lib-master/master-service-settings.c @@ -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 = { diff --git a/src/lib-master/master-service-settings.h b/src/lib-master/master-service-settings.h index 064e914a2e..ae29c48ff9 100644 --- a/src/lib-master/master-service-settings.h +++ b/src/lib-master/master-service-settings.h @@ -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 { diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index 5724b7b43c..e2dc98d583 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -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 == diff --git a/src/lib-master/master-service.h b/src/lib-master/master-service.h index 8308450493..95346b6a81 100644 --- a/src/lib-master/master-service.h +++ b/src/lib-master/master-service.h @@ -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 {