#define _GNU_SOURCE
#include <assert.h>
+#include <string.h>
#include <inttypes.h>
#include <urcu/list.h>
#include <urcu/uatomic.h>
int ret;
struct ltt_ust_session *usess = session->ust_session;
struct lttng_ht *chan_ht;
+ size_t len;
assert(session);
assert(attr);
assert(domain);
+ len = strnlen(attr->name, sizeof(attr->name));
+
+ /* Validate channel name */
+ if (attr->name[0] == '.' ||
+ memchr(attr->name, '/', len) != NULL) {
+ ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
+ goto end;
+ }
+
DBG("Enabling channel %s for session %s", attr->name, session->name);
rcu_read_lock();
error:
rcu_read_unlock();
+end:
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;
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) {
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;
}
/*