*/
#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <inttypes.h>
#include <urcu/list.h>
DBG3("Listing agent events");
+ rcu_read_lock();
nb_event = lttng_ht_get_count(agt->events);
+ rcu_read_unlock();
if (nb_event == 0) {
ret = nb_event;
goto error;
/*
* Command LTTNG_ENABLE_EVENT processed by the client thread.
+ * We own filter, exclusion, and filter_expression.
*/
int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
char *channel_name, struct lttng_event *event,
/* At this point, the session and channel exist on the tracer */
ret = event_ust_enable_tracepoint(usess, uchan, event,
filter_expression, filter, exclusion);
+ /* We have passed ownership */
+ filter_expression = NULL;
+ filter = NULL;
+ exclusion = NULL;
if (ret != LTTNG_OK) {
goto error;
}
assert(0);
}
- ret = cmd_enable_event(session, &tmp_dom, (char *) default_chan_name,
- &uevent, filter_expression, filter, NULL, wpipe);
+ {
+ struct lttng_filter_bytecode *filter_copy = NULL;
+
+ if (filter) {
+ filter_copy = zmalloc(
+ sizeof(struct lttng_filter_bytecode)
+ + filter->len);
+ if (!filter_copy) {
+ goto error;
+ }
+
+ memcpy(filter_copy, filter,
+ sizeof(struct lttng_filter_bytecode)
+ + filter->len);
+ }
+
+ ret = cmd_enable_event(session, &tmp_dom,
+ (char *) default_chan_name,
+ &uevent, filter_expression, filter_copy,
+ NULL, wpipe);
+ /* We have passed ownership */
+ filter_expression = NULL;
+ }
+
if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
goto error;
}
/* The wild card * means that everything should be enabled. */
if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
ret = event_agent_enable_all(usess, agt, event, filter);
+ filter = NULL;
} else {
ret = event_agent_enable(usess, agt, event, filter);
+ filter = NULL;
}
if (ret != LTTNG_OK) {
goto error;
ret = LTTNG_OK;
error:
+ free(filter_expression);
+ free(filter);
+ free(exclusion);
rcu_read_unlock();
return ret;
}
* possible to enable channel thus inform the client.
*/
if (usess && usess->domain_global.channels) {
+ rcu_read_lock();
nb_chan += lttng_ht_get_count(usess->domain_global.channels);
+ rcu_read_unlock();
}
if (ksession) {
nb_chan += ksession->channel_count;
DBG3("Listing domains found UST global domain");
nb_dom++;
+ rcu_read_lock();
cds_lfht_for_each_entry(session->ust_session->agents->ht, &iter.iter,
agt, node.node) {
if (agt->being_used) {
nb_dom++;
}
}
+ rcu_read_unlock();
}
if (!nb_dom) {
(*domains)[index].buf_type = session->ust_session->buffer_type;
index++;
+ rcu_read_lock();
cds_lfht_for_each_entry(session->ust_session->agents->ht, &iter.iter,
agt, node.node) {
if (agt->being_used) {
index++;
}
}
+ rcu_read_unlock();
}
end:
return nb_dom;
break;
case LTTNG_DOMAIN_UST:
if (session->ust_session != NULL) {
+ rcu_read_lock();
nb_chan = lttng_ht_get_count(
- session->ust_session->domain_global.channels);
+ session->ust_session->domain_global.channels);
+ rcu_read_unlock();
}
DBG3("Number of UST global channels %zd", nb_chan);
- if (nb_chan <= 0) {
+ if (nb_chan < 0) {
ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
+ goto error;
}
break;
default:
- *channels = NULL;
ret = LTTNG_ERR_UND;
goto error;
}
}
list_lttng_channels(domain, session, *channels);
- } else {
- *channels = NULL;
- /* Ret value was set in the domain switch case */
- goto error;
}
return nb_chan;
struct lttng_ht_iter iter;
struct agent *agt;
+ rcu_read_lock();
cds_lfht_for_each_entry(session->ust_session->agents->ht,
&iter.iter, agt, node.node) {
nb_event = list_lttng_agent_events(agt, events);
}
+ rcu_read_unlock();
}
break;
default:
struct lttng_snapshot_output **outputs)
{
int ret, idx = 0;
- struct lttng_snapshot_output *list;
+ struct lttng_snapshot_output *list = NULL;
struct lttng_ht_iter iter;
struct snapshot_output *output;
* set in no output mode.
*/
if (session->output_traces) {
- ret = LTTNG_ERR_EPERM;
+ ret = -LTTNG_ERR_EPERM;
goto error;
}
list = zmalloc(session->snapshot.nb_output * sizeof(*list));
if (!list) {
- ret = LTTNG_ERR_NOMEM;
+ ret = -LTTNG_ERR_NOMEM;
goto error;
}
/* Copy list from session to the new list object. */
+ rcu_read_lock();
cds_lfht_for_each_entry(session->snapshot.output_ht->ht, &iter.iter,
output, node.node) {
assert(output->consumer);
ret = uri_to_str_url(&output->consumer->dst.net.control,
list[idx].ctrl_url, sizeof(list[idx].ctrl_url));
if (ret < 0) {
- ret = LTTNG_ERR_NOMEM;
- goto free_error;
+ ret = -LTTNG_ERR_NOMEM;
+ goto error;
}
/* Data URI. */
ret = uri_to_str_url(&output->consumer->dst.net.data,
list[idx].data_url, sizeof(list[idx].data_url));
if (ret < 0) {
- ret = LTTNG_ERR_NOMEM;
- goto free_error;
+ ret = -LTTNG_ERR_NOMEM;
+ goto error;
}
}
idx++;
}
*outputs = list;
- return session->snapshot.nb_output;
-
-free_error:
- free(list);
+ list = NULL;
+ ret = session->snapshot.nb_output;
error:
- return -ret;
+ free(list);
+ rcu_read_unlock();
+ return ret;
}
/*
struct ltt_ust_channel *uchan;
struct ltt_ust_session *usess = session->ust_session;
+ rcu_read_lock();
cds_lfht_for_each_entry(usess->domain_global.channels->ht, &iter.iter,
uchan, node.node) {
if (uchan->attr.subbuf_size > max_size) {
max_size = uchan->attr.subbuf_size;
}
}
+ rcu_read_unlock();
}
return max_size;