X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmain.c;h=bb84be1ad1475ee491ad9d2e807b481f56f522fb;hb=90aa04a116a8be510b9d256b47de6bbb4144fb8b;hp=9f8c9a332fea3fd28879324e86922af3e8c27edc;hpb=b69a1b4064e50db1192d79fd92305182cfc5829e;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 9f8c9a332..bb84be1ad 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -49,9 +49,9 @@ #include "consumer.h" #include "context.h" #include "event.h" +#include "event-notifier-error-accounting.h" #include "kernel.h" #include "kernel-consumer.h" -#include "shm.h" #include "lttng-ust-ctl.h" #include "ust-consumer.h" #include "utils.h" @@ -83,6 +83,8 @@ NULL #endif ; +#define EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX 65535 + const char *progname; static int lockfile_fd = -1; static int opt_print_version; @@ -120,6 +122,7 @@ static const struct option long_options[] = { { "load", required_argument, 0, 'l' }, { "kmod-probes", required_argument, 0, '\0' }, { "extra-kmod-probes", required_argument, 0, '\0' }, + { "event-notifier-error-number-of-bucket", required_argument, 0, '\0' }, { NULL, 0, 0, 0 } }; @@ -314,6 +317,9 @@ static void sessiond_cleanup(void) pthread_mutex_destroy(&session_list->lock); + DBG("Cleaning up all per-event notifier domain agents"); + agent_by_event_notifier_domain_ht_destroy(); + DBG("Cleaning up all agent apps"); agent_app_ht_clean(); DBG("Closing all UST sockets"); @@ -694,6 +700,23 @@ static int set_option(int opt, const char *arg, const char *optname) ret = -ENOMEM; } } + } else if (string_match(optname, "event-notifier-error-number-of-bucket")) { + unsigned long v; + + errno = 0; + v = strtoul(arg, NULL, 0); + if (errno != 0 || !isdigit(arg[0])) { + ERR("Wrong value in --event-notifier-error-number-of-bucket parameter: %s", arg); + return -1; + } + if (v == 0 || v >= EVENT_NOTIFIER_ERROR_COUNTER_NUMBER_OF_BUCKET_MAX) { + ERR("Value out of range for --event-notifier-error-number-of-bucket parameter: %s", arg); + return -1; + } + config.event_notifier_error_counter_bucket = (int) v; + DBG3("Number of event notifier error counter set to non default: %i", + config.event_notifier_error_counter_bucket); + goto end; } else if (string_match(optname, "config") || opt == 'f') { /* This is handled in set_options() thus silent skip. */ goto end; @@ -1586,6 +1609,8 @@ int main(int argc, char **argv) goto stop_threads; } + event_notifier_error_accounting_init(config.event_notifier_error_counter_bucket); + /* * Initialize agent app hash table. We allocate the hash table here * since cleanup() can get called after this point. @@ -1596,6 +1621,11 @@ int main(int argc, char **argv) goto stop_threads; } + if (agent_by_event_notifier_domain_ht_create()) { + ERR("Failed to allocate per-event notifier domain agent hash table"); + retval = -1; + goto stop_threads; + } /* * These actions must be executed as root. We do that *after* setting up * the sockets path because we MUST make the check for another daemon using @@ -1818,6 +1848,7 @@ int main(int argc, char **argv) sessiond_wait_for_quit_pipe(-1); stop_threads: + /* * Ensure that the client thread is no longer accepting new commands, * which could cause new sessions to be created. @@ -1867,6 +1898,13 @@ stop_threads: lttng_thread_put(notification_thread); } + /* + * Teardown of error accounting needs be done after the teardown of the + * notification thread as all error buckets must have been released by + * their users (conditions). + */ + event_notifier_error_accounting_fini(); + /* * Ensure all prior call_rcu are done. call_rcu callbacks may push * hash tables to the ht_cleanup thread. Therefore, we ensure that