X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=liblttng-ust%2Flttng-events.c;fp=liblttng-ust%2Flttng-events.c;h=6a089122c8d1a2afee87f1a77e353aa4d7467736;hb=ebabbf580131acd1fe246c4d31fc5c044d36a038;hp=66ec7b2ca7862715ca3295a179462266eaad4493;hpb=d37ecb3fc622dee6f80f84c21f38d32eef407262;p=deliverable%2Flttng-ust.git diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 66ec7b2c..6a089122 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -67,6 +67,7 @@ #include "ust-events-internal.h" #include "wait.h" #include "../libringbuffer/shm.h" +#include "../libcounter/counter.h" #include "jhash.h" #include @@ -171,6 +172,46 @@ struct lttng_session *lttng_session_create(void) return session; } +struct lttng_counter *lttng_ust_counter_create( + const char *counter_transport_name, + size_t number_dimensions, const struct lttng_counter_dimension *dimensions) +{ + struct lttng_counter_transport *counter_transport = NULL; + struct lttng_counter *counter = NULL; + + counter_transport = lttng_counter_transport_find(counter_transport_name); + if (!counter_transport) + goto notransport; + counter = zmalloc(sizeof(struct lttng_counter)); + if (!counter) + goto nomem; + + counter->ops = &counter_transport->ops; + counter->transport = counter_transport; + + counter->counter = counter->ops->counter_create( + number_dimensions, dimensions, 0, + -1, 0, NULL, false); + if (!counter->counter) { + goto create_error; + } + + return counter; + +create_error: + free(counter); +nomem: +notransport: + return NULL; +} + +static +void lttng_ust_counter_destroy(struct lttng_counter *counter) +{ + counter->ops->counter_destroy(counter->counter); + free(counter); +} + struct lttng_event_notifier_group *lttng_event_notifier_group_create(void) { struct lttng_event_notifier_group *event_notifier_group; @@ -352,7 +393,10 @@ void lttng_event_notifier_group_destroy( &event_notifier_group->event_notifiers_head, node) _lttng_event_notifier_destroy(notifier); - /* Close the notification fd to the listener of event notifiers. */ + if (event_notifier_group->error_counter) + lttng_ust_counter_destroy(event_notifier_group->error_counter); + + /* Close the notification fd to the listener of event_notifiers. */ lttng_ust_lock_fd_tracker(); close_ret = close(event_notifier_group->notification_fd);