Mercurial > dovecot > core-2.2
changeset 12372:4d91cec713cf
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.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 03 Nov 2010 15:23:52 +0000 |
parents | 3ce7879e3ac0 |
children | 7b1aae5f7bd5 |
files | 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 |
diffstat | 4 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-master/master-service-settings.c Wed Nov 03 14:59:39 2010 +0000 +++ b/src/lib-master/master-service-settings.c Wed Nov 03 15:23:52 2010 +0000 @@ -41,6 +41,7 @@ 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 @@ .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 = {
--- a/src/lib-master/master-service-settings.h Wed Nov 03 14:59:39 2010 +0000 +++ b/src/lib-master/master-service-settings.h Wed Nov 03 15:23:52 2010 +0000 @@ -15,6 +15,7 @@ uoff_t config_cache_size; bool version_ignore; bool shutdown_clients; + bool verbose_proctitle; }; struct master_service_settings_input {
--- a/src/lib-master/master-service.c Wed Nov 03 14:59:39 2010 +0000 +++ b/src/lib-master/master-service.c Wed Nov 03 15:23:52 2010 +0000 @@ -827,6 +827,15 @@ 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 ==
--- a/src/lib-master/master-service.h Wed Nov 03 14:59:39 2010 +0000 +++ b/src/lib-master/master-service.h Wed Nov 03 15:23:52 2010 +0000 @@ -19,7 +19,10 @@ /* 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 {