int *shm_fd, int *wait_fd,
uint64_t *memory_map_size);
-struct ltt_event *ltt_event_create(struct ltt_channel *chan,
- struct lttng_ust_event *event_param,
- void *filter);
+int ltt_event_create(struct ltt_channel *chan,
+ struct lttng_ust_event *event_param,
+ void *filter,
+ struct ltt_event **event);
int ltt_channel_enable(struct ltt_channel *channel);
int ltt_channel_disable(struct ltt_channel *channel);
/*
* Supports event creation while tracing session is active.
*/
-struct ltt_event *ltt_event_create(struct ltt_channel *chan,
- struct lttng_ust_event *event_param,
- void *filter)
+int ltt_event_create(struct ltt_channel *chan,
+ struct lttng_ust_event *event_param,
+ void *filter,
+ struct ltt_event **_event)
{
struct ltt_event *event;
- int ret;
+ int ret = 0;
- if (chan->used_event_id == -1UL)
+ if (chan->used_event_id == -1UL) {
+ ret = -ENOMEM;
goto full;
+ }
/*
* This is O(n^2) (for each event, the loop is called at event
* creation). Might require a hash if we have lots of events.
*/
- cds_list_for_each_entry(event, &chan->session->events, list)
- if (event->desc && !strcmp(event->desc->name, event_param->name))
+ cds_list_for_each_entry(event, &chan->session->events, list) {
+ if (event->desc && !strcmp(event->desc->name, event_param->name)) {
+ ret = -EEXIST;
goto exist;
+ }
+ }
event = zmalloc(sizeof(struct ltt_event));
- if (!event)
+ if (!event) {
+ ret = -ENOMEM;
goto cache_error;
+ }
event->chan = chan;
event->filter = filter;
/*
goto statedump_error;
}
cds_list_add(&event->list, &chan->session->events);
- return event;
+ *_event = event;
+ return 0;
statedump_error:
if (event->desc) {
cache_error:
exist:
full:
- return NULL;
+ return ret;
}
/*
.name = "lttng_ust:metadata",
};
struct ltt_event *event;
+ int ret;
/*
* We tolerate no failure path after event creation. It will stay
* invariant for the rest of the session.
*/
- event = ltt_event_create(channel, &metadata_params, NULL);
- if (!event) {
+ ret = ltt_event_create(channel, &metadata_params, NULL, &event);
+ if (ret < 0) {
goto create_error;
}
return;
* We tolerate no failure path after event creation. It will stay
* invariant for the rest of the session.
*/
- event = ltt_event_create(channel, event_param, NULL);
- if (!event) {
- ret = -EINVAL;
+ ret = ltt_event_create(channel, event_param, NULL, &event);
+ if (ret < 0) {
goto event_error;
}
objd_set_private(event_objd, event);