Add target arch and paths to the configure output
[lttng-tools.git] / lttng-sessiond / event.c
index 90b10ec3a64e6b4b5defa62e2ccc3a17f22df225..1068707438082e2758e80105599c050967d3e581 100644 (file)
 #include <string.h>
 
 #include <lttng/lttng.h>
+#include <lttng-ht.h>
 #include <lttng-sessiond-comm.h>
 #include <lttngerr.h>
 
 #include "channel.h"
 #include "event.h"
-#include "hashtable.h"
 #include "kernel.h"
 #include "ust-ctl.h"
 #include "ust-app.h"
@@ -260,7 +260,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
 {
        int ret, i;
        size_t size;
-       struct cds_lfht_iter iter;
+       struct lttng_ht_iter iter;
        struct ltt_ust_event *uevent = NULL;
        struct lttng_event *events = NULL;
 
@@ -268,7 +268,8 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST:
        {
                /* Enable existing events */
-               cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) {
+               cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent,
+                               node.node) {
                        if (uevent->enabled == 0) {
                                ret = ust_app_enable_event_glb(usess, uchan, uevent);
                                if (ret < 0) {
@@ -327,7 +328,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
                        uevent->enabled = 1;
                        /* Add ltt ust event to channel */
                        rcu_read_lock();
-                       hashtable_add_unique(uchan->events, &uevent->node);
+                       lttng_ht_add_unique_str(uchan->events, &uevent->node);
                        rcu_read_unlock();
                }
 
@@ -358,7 +359,7 @@ error:
 int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
                struct ltt_ust_channel *uchan, struct lttng_event *event)
 {
-       int ret, to_create = 0;
+       int ret = LTTCOMM_OK, to_create = 0;
        struct ltt_ust_event *uevent;
 
        uevent = trace_ust_find_event_by_name(uchan->events, event->name);
@@ -368,6 +369,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
                        ret = LTTCOMM_FATAL;
                        goto error;
                }
+               /* Valid to set it after the goto error since uevent is still NULL */
                to_create = 1;
        }
 
@@ -376,6 +378,8 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
                goto end;
        }
 
+       uevent->enabled = 1;
+
        switch (domain) {
        case LTTNG_DOMAIN_UST:
        {
@@ -406,22 +410,33 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
                goto end;
        }
 
-       uevent->enabled = 1;
-       /* Add ltt ust event to channel */
        if (to_create) {
                rcu_read_lock();
-               hashtable_add_unique(uchan->events, &uevent->node);
+               /* Add ltt ust event to channel */
+               lttng_ht_add_unique_str(uchan->events, &uevent->node);
                rcu_read_unlock();
        }
 
        DBG("Event UST %s %s in channel %s", uevent->attr.name,
                        to_create ? "created" : "enabled", uchan->name);
 
+       ret = LTTCOMM_OK;
+
 end:
-       return LTTCOMM_OK;
+       return ret;
 
 error:
-       trace_ust_destroy_event(uevent);
+       /*
+        * Only destroy event on creation time (not enabling time) because if the
+        * event is found in the channel (to_create == 0), it means that at some
+        * point the enable_event worked and it's thus valid to keep it alive.
+        * Destroying it also implies that we also destroy it's shadow copy to sync
+        * everyone up.
+        */
+       if (to_create) {
+               /* In this code path, the uevent was not added to the hash table */
+               trace_ust_destroy_event(uevent);
+       }
        return ret;
 }
 
@@ -481,7 +496,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
 {
        int ret, i;
        size_t size;
-       struct cds_lfht_iter iter;
+       struct lttng_ht_iter iter;
        struct ltt_ust_event *uevent = NULL;
        struct lttng_event *events = NULL;
 
@@ -489,7 +504,8 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST:
        {
                /* Disabling existing events */
-               cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) {
+               cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent,
+                               node.node) {
                        if (uevent->enabled == 1) {
                                ret = ust_app_disable_event_glb(usess, uchan, uevent);
                                if (ret < 0) {
This page took 0.024878 seconds and 4 git commands to generate.