struct stats_client *stats_client;
struct master_service_haproxy_conn *haproxy_conns;
+ struct event_filter *process_shutdown_filter;
bool killed:1;
bool stopping:1;
DEF(STR, log_timestamp),
DEF(STR, log_debug),
DEF(STR, log_core_filter),
+ DEF(STR, process_shutdown_filter),
DEF(STR, syslog_facility),
DEF(STR, import_environment),
DEF(STR, stats_writer_socket_path),
.log_timestamp = DEFAULT_FAILURE_STAMP_FORMAT,
.log_debug = "",
.log_core_filter = "",
+ .process_shutdown_filter = "",
.syslog_facility = "mail",
.import_environment = "TZ CORE_OUTOFMEM CORE_ERROR" ENV_SYSTEMD ENV_GDB,
.stats_writer_socket_path = "stats-writer",
return TRUE;
}
+static void
+master_service_set_process_shutdown_filter_wrapper(struct event_filter *filter)
+{
+ master_service_set_process_shutdown_filter(master_service, filter);
+}
+
static bool
master_service_settings_check(void *_set, pool_t pool ATTR_UNUSED,
const char **error_r)
if (!setting_filter_parse("log_core_filter", set->log_core_filter,
event_set_global_core_log_filter, error_r))
return FALSE;
+ if (!setting_filter_parse("process_shutdown_filter",
+ set->process_shutdown_filter,
+ master_service_set_process_shutdown_filter_wrapper,
+ error_r))
+ return FALSE;
return TRUE;
}
/* </settings checks> */
const char *log_timestamp;
const char *log_debug;
const char *log_core_filter;
+ const char *process_shutdown_filter;
const char *syslog_facility;
const char *import_environment;
const char *stats_writer_socket_path;
static bool
master_service_event_callback(struct event *event,
enum event_callback_type type,
- struct failure_context *ctx ATTR_UNUSED,
+ struct failure_context *ctx,
const char *fmt ATTR_UNUSED,
va_list args ATTR_UNUSED)
{
inherit the category from them. */
event_add_category(event, &master_service_category);
}
+ /* This callback may be called while still in master_service_init().
+ In that case master_service is NULL. */
+ if (type == EVENT_CALLBACK_TYPE_SEND && master_service != NULL &&
+ event_filter_match(master_service->process_shutdown_filter,
+ event, ctx))
+ master_service_stop_new_connections(master_service);
return TRUE;
}
} T_END;
return ret;
}
+
+void master_service_set_process_shutdown_filter(struct master_service *service,
+ struct event_filter *filter)
+{
+ master_service_unset_process_shutdown_filter(service);
+ service->process_shutdown_filter = filter;
+ event_filter_ref(service->process_shutdown_filter);
+}
+
+void master_service_unset_process_shutdown_filter(struct master_service *service)
+{
+ event_filter_unref(&service->process_shutdown_filter);
+}
unsigned major_version,
unsigned int *minor_version_r);
+/* Sets process shutdown filter */
+void master_service_set_process_shutdown_filter(struct master_service *service,
+ struct event_filter *filter);
+/* Unsets process shutdown filter, if it exists */
+void master_service_unset_process_shutdown_filter(struct master_service *service);
+
#endif