#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"
}
static
-int lttng_is_channel_ready(struct lttng_channel *lttng_chan)
+int lttng_is_channel_ready(struct lttng_ust_channel_buffer *lttng_chan)
{
- struct channel *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;
}
static
int lttng_abi_create_session(void *owner)
{
- struct lttng_session *session;
+ struct lttng_ust_session *session;
int session_objd, ret;
session = lttng_session_create();
long lttng_abi_add_context(int objd,
struct lttng_ust_abi_context *context_param,
union lttng_ust_abi_args *uargs,
- struct lttng_ctx **ctx, struct lttng_session *session)
+ struct lttng_ust_ctx **ctx, struct lttng_ust_session *session)
{
return lttng_attach_context(context_param, uargs, ctx, session);
}
union lttng_ust_abi_args *uargs,
void *owner)
{
- struct lttng_session *session = objd_private(session_objd);
+ struct lttng_ust_session *session = objd_private(session_objd);
const char *transport_name;
- const struct lttng_transport *transport;
+ struct lttng_transport *transport;
const char *chan_name;
int chan_objd;
struct lttng_ust_shm_handle *channel_handle;
- struct lttng_channel *lttng_chan;
- struct channel *chan;
+ struct lttng_ust_abi_channel_config *lttng_chan_config;
+ struct lttng_ust_channel_buffer *lttng_chan_buf;
+ struct lttng_ust_lib_ring_buffer_channel *chan;
struct lttng_ust_lib_ring_buffer_config *config;
void *chan_data;
int wakeup_fd;
goto active; /* Refuse to add channel to active session */
}
+ lttng_chan_buf = lttng_ust_alloc_channel_buffer();
+ if (!lttng_chan_buf) {
+ ret = -ENOMEM;
+ goto lttng_chan_buf_error;
+ }
+
channel_handle = channel_handle_create(chan_data, len, wakeup_fd);
if (!channel_handle) {
ret = -EINVAL;
assert(chan);
chan->handle = channel_handle;
config = &chan->backend.config;
- lttng_chan = channel_get_private(chan);
- if (!lttng_chan) {
+ lttng_chan_config = channel_get_private_config(chan);
+ if (!lttng_chan_config) {
ret = -EINVAL;
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:
ret = -EINVAL;
goto notransport;
}
- transport = lttng_transport_find(transport_name);
+ transport = lttng_ust_transport_find(transport_name);
if (!transport) {
DBG("LTTng transport %s not found\n",
transport_name);
}
/* Initialize our lttng chan */
- lttng_chan->chan = chan;
- lttng_chan->tstate = 1;
- lttng_chan->enabled = 1;
- lttng_chan->ctx = NULL;
- lttng_chan->session = session;
- lttng_chan->ops = &transport->ops;
- memcpy(<tng_chan->chan->backend.config,
+ lttng_chan_buf->parent->enabled = 1;
+ lttng_chan_buf->parent->session = session;
+
+ 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;
+
+ memcpy(&chan->backend.config,
transport->client_config,
- sizeof(lttng_chan->chan->backend.config));
- cds_list_add(<tng_chan->node, &session->priv->chan_head);
- lttng_chan->header_type = 0;
- lttng_chan->handle = channel_handle;
- lttng_chan->type = type;
+ sizeof(chan->backend.config));
+ cds_list_add(<tng_chan_buf->priv->node, &session->priv->chan_head);
+ lttng_chan_buf->priv->header_type = 0;
+ lttng_chan_buf->priv->type = type;
+ /* Copy fields from lttng ust chan config. */
+ lttng_chan_buf->priv->id = lttng_chan_config->id;
+ memcpy(lttng_chan_buf->priv->uuid, lttng_chan_config->uuid, LTTNG_UST_UUID_LEN);
+ channel_set_private(chan, lttng_chan_buf);
/*
* We tolerate no failure path after channel creation. It will stay
* invariant for the rest of the session.
*/
- objd_set_private(chan_objd, lttng_chan);
- lttng_chan->objd = chan_objd;
+ objd_set_private(chan_objd, lttng_chan_buf);
+ lttng_chan_buf->priv->parent.objd = chan_objd;
/* The channel created holds a reference on the session */
objd_ref(session_objd);
return chan_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);
return ret;
handle_error:
+ lttng_ust_free_channel_common(lttng_chan_buf->parent);
+lttng_chan_buf_error:
active:
invalid:
return ret;
long lttng_session_cmd(int objd, unsigned int cmd, unsigned long arg,
union lttng_ust_abi_args *uargs, void *owner)
{
- struct lttng_session *session = objd_private(objd);
+ struct lttng_ust_session *session = objd_private(objd);
switch (cmd) {
case LTTNG_UST_ABI_CHANNEL:
static
int lttng_release_session(int objd)
{
- struct lttng_session *session = objd_private(objd);
+ struct lttng_ust_session *session = objd_private(objd);
if (session) {
lttng_session_destroy(session);
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);
int lttng_abi_map_stream(int channel_objd, struct lttng_ust_abi_stream *info,
union lttng_ust_abi_args *uargs, void *owner)
{
- struct lttng_channel *channel = objd_private(channel_objd);
+ struct lttng_ust_channel_buffer *lttng_chan_buf = objd_private(channel_objd);
int ret;
- ret = channel_handle_add_stream(channel->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)
void *owner,
enum lttng_enabler_format_type format_type)
{
- struct lttng_channel *channel = objd_private(channel_objd);
+ struct lttng_ust_channel_buffer *channel = objd_private(channel_objd);
struct lttng_event_enabler *enabler;
int event_objd, ret;
long lttng_channel_cmd(int objd, unsigned int cmd, unsigned long arg,
union lttng_ust_abi_args *uargs, void *owner)
{
- struct lttng_channel *channel = objd_private(objd);
+ struct lttng_ust_channel_buffer *lttng_chan_buf = objd_private(objd);
if (cmd != LTTNG_UST_ABI_STREAM) {
/*
* Check if channel received all streams.
*/
- if (!lttng_is_channel_ready(channel))
+ if (!lttng_is_channel_ready(lttng_chan_buf))
return -EPERM;
}
case LTTNG_UST_ABI_CONTEXT:
return lttng_abi_add_context(objd,
(struct lttng_ust_abi_context *) arg, uargs,
- &channel->ctx, channel->session);
+ <tng_chan_buf->priv->ctx,
+ lttng_chan_buf->parent->session);
case LTTNG_UST_ABI_ENABLE:
- return lttng_channel_enable(channel);
+ return lttng_channel_enable(lttng_chan_buf->parent);
case LTTNG_UST_ABI_DISABLE:
- return lttng_channel_disable(channel);
+ return lttng_channel_disable(lttng_chan_buf->parent);
case LTTNG_UST_ABI_FLUSH_BUFFER:
- return channel->ops->flush_buffer(channel->chan, channel->handle);
+ return lttng_chan_buf->ops->priv->flush_buffer(lttng_chan_buf);
default:
return -EINVAL;
}
static
int lttng_channel_release(int objd)
{
- struct lttng_channel *channel = objd_private(objd);
+ struct lttng_ust_channel_buffer *lttng_chan_buf = objd_private(objd);
- if (channel)
- return lttng_ust_abi_objd_unref(channel->session->priv->objd, 0);
+ if (lttng_chan_buf)
+ return lttng_ust_abi_objd_unref(lttng_chan_buf->parent->session->priv->objd, 0);
return 0;
}
struct lttng_event_enabler *event_enabler = objd_private(objd);
if (event_enabler)
- return lttng_ust_abi_objd_unref(event_enabler->chan->objd, 0);
+ return lttng_ust_abi_objd_unref(event_enabler->chan->priv->parent.objd, 0);
return 0;
}