Fix: pass private data to context callbacks
[lttng-ust.git] / liblttng-ust / lttng-ust-abi.c
index 53ca5dbe28ef7f2f8dfc82344cc7b5d454bf627d..61105ace6dccd9d83e00865454e7580252b21199 100644 (file)
@@ -39,6 +39,7 @@
 #include <usterr-signal-safe.h>
 
 #include "../libringbuffer/frontend_types.h"
+#include "../libringbuffer/frontend.h"
 #include "../libringbuffer/shm.h"
 #include "../libcounter/counter.h"
 #include "tracepoint-internal.h"
@@ -292,8 +293,8 @@ int lttng_is_channel_ready(struct lttng_ust_channel_buffer *lttng_chan)
        struct lttng_ust_lib_ring_buffer_channel *chan;
        unsigned int nr_streams, exp_streams;
 
-       chan = lttng_chan->chan;
-       nr_streams = channel_handle_get_nr_streams(lttng_chan->handle);
+       chan = lttng_chan->priv->rb_chan;
+       nr_streams = channel_handle_get_nr_streams(lttng_chan->priv->rb_chan->handle);
        exp_streams = chan->nr_streams;
        return nr_streams == exp_streams;
 }
@@ -322,7 +323,7 @@ objd_error:
 }
 
 static
-long lttng_abi_tracer_version(int objd,
+long lttng_abi_tracer_version(int objd __attribute__((unused)),
        struct lttng_ust_abi_tracer_version *v)
 {
        v->major = LTTNG_UST_MAJOR_VERSION;
@@ -376,7 +377,7 @@ fd_error:
 }
 
 static
-long lttng_abi_add_context(int objd,
+long lttng_abi_add_context(int objd __attribute__((unused)),
        struct lttng_ust_abi_context *context_param,
        union lttng_ust_abi_args *uargs,
        struct lttng_ust_ctx **ctx, struct lttng_ust_session *session)
@@ -502,6 +503,11 @@ int lttng_abi_map_channel(int session_objd,
                goto alloc_error;
        }
 
+       if (lttng_ust_session_uuid_validate(session, lttng_chan_config->uuid)) {
+               ret = -EINVAL;
+               goto uuid_error;
+       }
+
        /* Lookup transport name */
        switch (type) {
        case LTTNG_UST_ABI_CHAN_PER_CPU:
@@ -549,10 +555,9 @@ int lttng_abi_map_channel(int session_objd,
 
        lttng_chan_buf->priv->parent.tstate = 1;
        lttng_chan_buf->priv->ctx = NULL;
+       lttng_chan_buf->priv->rb_chan = chan;
 
        lttng_chan_buf->ops = &transport->ops;
-       lttng_chan_buf->chan = chan;
-       lttng_chan_buf->handle = channel_handle;
 
        memcpy(&chan->backend.config,
                transport->client_config,
@@ -578,6 +583,7 @@ int lttng_abi_map_channel(int session_objd,
        /* error path after channel was created */
 objd_error:
 notransport:
+uuid_error:
 alloc_error:
        channel_destroy(chan, channel_handle, 0);
        lttng_ust_free_channel_common(lttng_chan_buf->parent);
@@ -708,7 +714,8 @@ objd_error:
 
 static
 long lttng_event_notifier_enabler_cmd(int objd, unsigned int cmd, unsigned long arg,
-               union lttng_ust_abi_args *uargs, void *owner)
+               union lttng_ust_abi_args *uargs __attribute__((unused)),
+               void *owner __attribute__((unused)))
 {
        struct lttng_event_notifier_enabler *event_notifier_enabler = objd_private(objd);
        switch (cmd) {
@@ -749,7 +756,7 @@ long lttng_event_notifier_enabler_cmd(int objd, unsigned int cmd, unsigned long
  */
 static
 long lttng_event_notifier_group_error_counter_cmd(int objd, unsigned int cmd, unsigned long arg,
-       union lttng_ust_abi_args *uargs, void *owner)
+       union lttng_ust_abi_args *uargs, void *owner __attribute__((unused)))
 {
        int ret;
        struct lttng_counter *counter = objd_private(objd);
@@ -779,7 +786,8 @@ long lttng_event_notifier_group_error_counter_cmd(int objd, unsigned int cmd, un
        return ret;
 }
 
-__attribute__((visibility("hidden")))
+int lttng_release_event_notifier_group_error_counter(int objd)
+       __attribute__((visibility("hidden")));
 int lttng_release_event_notifier_group_error_counter(int objd)
 {
        struct lttng_counter *counter = objd_private(objd);
@@ -949,7 +957,8 @@ static const struct lttng_ust_abi_objd_ops lttng_event_notifier_group_ops = {
 
 static
 long lttng_tracepoint_list_cmd(int objd, unsigned int cmd, unsigned long arg,
-       union lttng_ust_abi_args *uargs, void *owner)
+       union lttng_ust_abi_args *uargs __attribute__((unused)),
+       void *owner __attribute__((unused)))
 {
        struct lttng_ust_tracepoint_list *list = objd_private(objd);
        struct lttng_ust_abi_tracepoint_iter *tp =
@@ -1029,7 +1038,8 @@ static const struct lttng_ust_abi_objd_ops lttng_tracepoint_list_ops = {
 
 static
 long lttng_tracepoint_field_list_cmd(int objd, unsigned int cmd,
-       unsigned long arg, union lttng_ust_abi_args *uargs, void *owner)
+       unsigned long arg __attribute__((unused)), union lttng_ust_abi_args *uargs,
+       void *owner __attribute__((unused)))
 {
        struct lttng_ust_field_list *list = objd_private(objd);
        struct lttng_ust_abi_field_iter *tp = &uargs->field_list.entry;
@@ -1109,12 +1119,12 @@ static const struct lttng_ust_abi_objd_ops lttng_tracepoint_field_list_ops = {
 
 static
 int lttng_abi_map_stream(int channel_objd, struct lttng_ust_abi_stream *info,
-               union lttng_ust_abi_args *uargs, void *owner)
+               union lttng_ust_abi_args *uargs, void *owner __attribute__((unused)))
 {
        struct lttng_ust_channel_buffer *lttng_chan_buf = objd_private(channel_objd);
        int ret;
 
-       ret = channel_handle_add_stream(lttng_chan_buf->handle,
+       ret = channel_handle_add_stream(lttng_chan_buf->priv->rb_chan->handle,
                uargs->stream.shm_fd, uargs->stream.wakeup_fd,
                info->stream_nr, info->len);
        if (ret)
@@ -1245,8 +1255,7 @@ long lttng_channel_cmd(int objd, unsigned int cmd, unsigned long arg,
        case LTTNG_UST_ABI_DISABLE:
                return lttng_channel_disable(lttng_chan_buf->parent);
        case LTTNG_UST_ABI_FLUSH_BUFFER:
-               return lttng_chan_buf->ops->priv->flush_buffer(lttng_chan_buf->chan,
-                               lttng_chan_buf->handle);
+               return lttng_chan_buf->ops->priv->flush_buffer(lttng_chan_buf);
        default:
                return -EINVAL;
        }
@@ -1291,7 +1300,8 @@ static const struct lttng_ust_abi_objd_ops lttng_channel_ops = {
  */
 static
 long lttng_event_enabler_cmd(int objd, unsigned int cmd, unsigned long arg,
-       union lttng_ust_abi_args *uargs, void *owner)
+       union lttng_ust_abi_args *uargs __attribute__((unused)),
+       void *owner __attribute__((unused)))
 {
        struct lttng_event_enabler *enabler = objd_private(objd);
 
This page took 0.026238 seconds and 4 git commands to generate.