Refactoring: remove ring buffer channel pointer from struct lttng_ust_channel_buffer
[lttng-ust.git] / liblttng-ust / lttng-events.c
index 9c1a9da1145433919434784c501247b68e7de198..c81581b228e960ae2f1ae4ff2b44517cb842fca7 100644 (file)
@@ -53,6 +53,7 @@
 #include "ust-events-internal.h"
 #include "wait.h"
 #include "../libringbuffer/shm.h"
+#include "../libringbuffer/frontend_types.h"
 #include "../libcounter/counter.h"
 #include "jhash.h"
 #include <lttng/ust-abi.h>
@@ -236,9 +237,9 @@ void _lttng_channel_unmap(struct lttng_ust_channel_buffer *lttng_chan)
        struct lttng_ust_shm_handle *handle;
 
        cds_list_del(&lttng_chan->priv->node);
-       lttng_destroy_context(lttng_chan->ctx);
-       chan = lttng_chan->chan;
-       handle = lttng_chan->handle;
+       lttng_destroy_context(lttng_chan->priv->ctx);
+       chan = lttng_chan->priv->rb_chan;
+       handle = chan->handle;
        channel_destroy(chan, handle, 0);
        free(lttng_chan->parent);
        free(lttng_chan->priv);
@@ -577,7 +578,7 @@ int lttng_session_enable(struct lttng_ust_session *session)
                /* don't change it if session stop/restart */
                if (chan->header_type)
                        continue;
-               ctx = chan->pub->ctx;
+               ctx = chan->ctx;
                if (ctx) {
                        nr_fields = ctx->nr_fields;
                        fields = ctx->fields;
@@ -750,9 +751,10 @@ int lttng_event_recorder_create(struct lttng_ust_event_desc *desc,
        event_recorder->chan = chan;
 
        /* Event will be enabled by enabler sync. */
+       event_recorder->parent->run_filter = lttng_ust_interpret_event_filter;
        event_recorder->parent->enabled = 0;
        event_recorder->parent->priv->registered = 0;
-       CDS_INIT_LIST_HEAD(&event_recorder->parent->filter_bytecode_runtime_head);
+       CDS_INIT_LIST_HEAD(&event_recorder->parent->priv->filter_bytecode_runtime_head);
        CDS_INIT_LIST_HEAD(&event_recorder->parent->priv->enablers_ref_head);
        event_recorder->parent->priv->desc = desc;
 
@@ -847,11 +849,12 @@ int lttng_event_notifier_create(struct lttng_ust_event_desc *desc,
        event_notifier_priv->error_counter_index = error_counter_index;
 
        /* Event notifier will be enabled by enabler sync. */
+       event_notifier->parent->run_filter = lttng_ust_interpret_event_filter;
        event_notifier->parent->enabled = 0;
        event_notifier_priv->parent.registered = 0;
 
-       CDS_INIT_LIST_HEAD(&event_notifier->parent->filter_bytecode_runtime_head);
-       CDS_INIT_LIST_HEAD(&event_notifier->capture_bytecode_runtime_head);
+       CDS_INIT_LIST_HEAD(&event_notifier->parent->priv->filter_bytecode_runtime_head);
+       CDS_INIT_LIST_HEAD(&event_notifier->priv->capture_bytecode_runtime_head);
        CDS_INIT_LIST_HEAD(&event_notifier_priv->parent.enablers_ref_head);
        event_notifier_priv->parent.desc = desc;
        event_notifier->notification_send = lttng_event_notifier_notification_send;
@@ -1238,7 +1241,7 @@ int lttng_event_enabler_ref_event_recorders(struct lttng_event_enabler *event_en
                 */
                lttng_enabler_link_bytecode(event_recorder_priv->parent.desc,
                        &session->priv->ctx,
-                       &event_recorder_priv->pub->parent->filter_bytecode_runtime_head,
+                       &event_recorder_priv->parent.filter_bytecode_runtime_head,
                        &lttng_event_enabler_as_enabler(event_enabler)->filter_bytecode_head);
 
                /* TODO: merge event context. */
@@ -1321,7 +1324,7 @@ void _lttng_event_destroy(struct lttng_ust_event_common *event)
                /* Remove from event hash table. */
                cds_hlist_del(&event_recorder->priv->hlist);
 
-               lttng_destroy_context(event_recorder->ctx);
+               lttng_destroy_context(event_recorder->priv->ctx);
                free(event_recorder->parent);
                free(event_recorder->priv);
                free(event_recorder);
@@ -1654,7 +1657,8 @@ void lttng_session_sync_event_enablers(struct lttng_ust_session *session)
        cds_list_for_each_entry(event_recorder_priv, &session->priv->events_head, node) {
                struct lttng_enabler_ref *enabler_ref;
                struct lttng_ust_bytecode_runtime *runtime;
-               int enabled = 0, has_enablers_without_bytecode = 0;
+               int enabled = 0, has_enablers_without_filter_bytecode = 0;
+               int nr_filters = 0;
 
                /* Enable events */
                cds_list_for_each_entry(enabler_ref,
@@ -1689,18 +1693,21 @@ void lttng_session_sync_event_enablers(struct lttng_ust_session *session)
                                &event_recorder_priv->parent.enablers_ref_head, node) {
                        if (enabler_ref->ref->enabled
                                        && cds_list_empty(&enabler_ref->ref->filter_bytecode_head)) {
-                               has_enablers_without_bytecode = 1;
+                               has_enablers_without_filter_bytecode = 1;
                                break;
                        }
                }
-               event_recorder_priv->pub->parent->has_enablers_without_bytecode =
-                       has_enablers_without_bytecode;
+               event_recorder_priv->parent.has_enablers_without_filter_bytecode =
+                       has_enablers_without_filter_bytecode;
 
                /* Enable filters */
                cds_list_for_each_entry(runtime,
-                               &event_recorder_priv->pub->parent->filter_bytecode_runtime_head, node) {
-                       lttng_bytecode_filter_sync_state(runtime);
+                               &event_recorder_priv->parent.filter_bytecode_runtime_head, node) {
+                       lttng_bytecode_sync_state(runtime);
+                       nr_filters++;
                }
+               CMM_STORE_SHARED(event_recorder_priv->parent.pub->eval_filter,
+                       !(has_enablers_without_filter_bytecode || !nr_filters));
        }
        lttng_ust_tp_probe_prune_release_queue();
 }
@@ -1840,14 +1847,14 @@ int lttng_event_notifier_enabler_ref_event_notifiers(
                 */
                lttng_enabler_link_bytecode(event_notifier_priv->parent.desc,
                        &event_notifier_group->ctx,
-                       &event_notifier_priv->pub->parent->filter_bytecode_runtime_head,
+                       &event_notifier_priv->parent.filter_bytecode_runtime_head,
                        &lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)->filter_bytecode_head);
 
                /*
                 * Link capture bytecodes if not linked yet.
                 */
                lttng_enabler_link_bytecode(event_notifier_priv->parent.desc,
-                       &event_notifier_group->ctx, &event_notifier_priv->pub->capture_bytecode_runtime_head,
+                       &event_notifier_group->ctx, &event_notifier_priv->capture_bytecode_runtime_head,
                        &event_notifier_enabler->capture_bytecode_head);
 
                event_notifier_priv->num_captures = event_notifier_enabler->num_captures;
@@ -1872,7 +1879,8 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
        cds_list_for_each_entry(event_notifier_priv, &event_notifier_group->event_notifiers_head, node) {
                struct lttng_enabler_ref *enabler_ref;
                struct lttng_ust_bytecode_runtime *runtime;
-               int enabled = 0, has_enablers_without_bytecode = 0;
+               int enabled = 0, has_enablers_without_filter_bytecode = 0;
+               int nr_filters = 0, nr_captures = 0;
 
                /* Enable event_notifiers */
                cds_list_for_each_entry(enabler_ref,
@@ -1901,24 +1909,30 @@ void lttng_event_notifier_group_sync_enablers(struct lttng_event_notifier_group
                                &event_notifier_priv->parent.enablers_ref_head, node) {
                        if (enabler_ref->ref->enabled
                                        && cds_list_empty(&enabler_ref->ref->filter_bytecode_head)) {
-                               has_enablers_without_bytecode = 1;
+                               has_enablers_without_filter_bytecode = 1;
                                break;
                        }
                }
-               event_notifier_priv->pub->parent->has_enablers_without_bytecode =
-                       has_enablers_without_bytecode;
+               event_notifier_priv->parent.has_enablers_without_filter_bytecode =
+                       has_enablers_without_filter_bytecode;
 
                /* Enable filters */
                cds_list_for_each_entry(runtime,
-                               &event_notifier_priv->pub->parent->filter_bytecode_runtime_head, node) {
-                       lttng_bytecode_filter_sync_state(runtime);
+                               &event_notifier_priv->parent.filter_bytecode_runtime_head, node) {
+                       lttng_bytecode_sync_state(runtime);
+                       nr_filters++;
                }
+               CMM_STORE_SHARED(event_notifier_priv->parent.pub->eval_filter,
+                       !(has_enablers_without_filter_bytecode || !nr_filters));
 
                /* Enable captures. */
                cds_list_for_each_entry(runtime,
-                               &event_notifier_priv->pub->capture_bytecode_runtime_head, node) {
-                       lttng_bytecode_capture_sync_state(runtime);
+                               &event_notifier_priv->capture_bytecode_runtime_head, node) {
+                       lttng_bytecode_sync_state(runtime);
+                       nr_captures++;
                }
+               CMM_STORE_SHARED(event_notifier_priv->pub->eval_capture,
+                               !!nr_captures);
        }
        lttng_ust_tp_probe_prune_release_queue();
 }
@@ -1965,13 +1979,13 @@ void lttng_ust_context_set_session_provider(const char *name,
                if (ret)
                        abort();
                cds_list_for_each_entry(chan, &session_priv->chan_head, node) {
-                       ret = lttng_ust_context_set_provider_rcu(&chan->pub->ctx,
+                       ret = lttng_ust_context_set_provider_rcu(&chan->ctx,
                                        name, get_size, record, get_value);
                        if (ret)
                                abort();
                }
                cds_list_for_each_entry(event_recorder_priv, &session_priv->events_head, node) {
-                       ret = lttng_ust_context_set_provider_rcu(&event_recorder_priv->pub->ctx,
+                       ret = lttng_ust_context_set_provider_rcu(&event_recorder_priv->ctx,
                                        name, get_size, record, get_value);
                        if (ret)
                                abort();
@@ -2006,3 +2020,21 @@ void lttng_ust_context_set_event_notifier_group_provider(const char *name,
                        abort();
        }
 }
+
+int lttng_ust_session_uuid_validate(struct lttng_ust_session *session,
+               unsigned char *uuid)
+{
+       if (!session)
+               return 0;
+       /* Compare UUID with session. */
+       if (session->priv->uuid_set) {
+               if (memcmp(session->priv->uuid, uuid, LTTNG_UST_UUID_LEN)) {
+                       return -1;
+               }
+       } else {
+               memcpy(session->priv->uuid, uuid, LTTNG_UST_UUID_LEN);
+               session->priv->uuid_set = true;
+       }
+       return 0;
+
+}
This page took 0.031019 seconds and 4 git commands to generate.