#include "channel.h"
#include "consumer.h"
#include "event.h"
+#include "health.h"
#include "kernel.h"
#include "kernel-consumer.h"
#include "lttng-sessiond.h"
/*
* Used to keep a unique index for each relayd socket created where this value
* is associated with streams on the consumer so it can match the right relayd
- * to send to.
- *
- * This value should be incremented atomically for safety purposes and future
- * possible concurrent access.
+ * to send to. It must be accessed with the relayd_net_seq_idx_lock
+ * held.
*/
-static unsigned int relayd_net_seq_idx;
+static pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER;
+static uint64_t relayd_net_seq_idx;
/*
* Create a session path used by list_lttng_sessions for the case that the
}
/* Set the network sequence index if not set. */
- if (consumer->net_seq_index == -1) {
+ if (consumer->net_seq_index == (uint64_t) -1ULL) {
+ pthread_mutex_lock(&relayd_net_seq_idx_lock);
/*
* Increment net_seq_idx because we are about to transfer the
* new relayd socket to the consumer.
+ * Assign unique key so the consumer can match streams.
*/
- uatomic_inc(&relayd_net_seq_idx);
- /* Assign unique key so the consumer can match streams */
- uatomic_set(&consumer->net_seq_index,
- uatomic_read(&relayd_net_seq_idx));
+ consumer->net_seq_index = ++relayd_net_seq_idx;
+ pthread_mutex_unlock(&relayd_net_seq_idx_lock);
}
/* Send relayd socket to consumer. */
goto error;
}
- ret = channel_ust_disable(usess, domain, uchan);
+ ret = channel_ust_disable(usess, uchan);
if (ret != LTTNG_OK) {
goto error;
}
* The wpipe arguments is used as a notifier for the kernel thread.
*/
int cmd_enable_channel(struct ltt_session *session,
- int domain, struct lttng_channel *attr, int wpipe)
+ struct lttng_domain *domain, struct lttng_channel *attr, int wpipe)
{
int ret;
struct ltt_ust_session *usess = session->ust_session;
assert(session);
assert(attr);
+ assert(domain);
DBG("Enabling channel %s for session %s", attr->name, session->name);
rcu_read_lock();
- switch (domain) {
+ switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{
struct ltt_kernel_channel *kchan;
uchan = trace_ust_find_channel_by_name(chan_ht, attr->name);
if (uchan == NULL) {
- ret = channel_ust_create(usess, domain, attr);
+ ret = channel_ust_create(usess, attr, domain->buf_type);
} else {
- ret = channel_ust_enable(usess, domain, uchan);
+ ret = channel_ust_enable(usess, uchan);
}
/* Start the UST session if the session was already started. */
}
break;
}
-#if 0
- case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
- case LTTNG_DOMAIN_UST_EXEC_NAME:
- case LTTNG_DOMAIN_UST_PID:
-#endif
default:
ret = LTTNG_ERR_UNKNOWN_DOMAIN;
goto error;
goto error;
}
- ret = event_ust_disable_tracepoint(usess, domain, uchan, event_name);
+ ret = event_ust_disable_tracepoint(usess, uchan, event_name);
if (ret != LTTNG_OK) {
goto error;
}
goto error;
}
- ret = event_ust_disable_all_tracepoints(usess, domain, uchan);
+ ret = event_ust_disable_all_tracepoints(usess, uchan);
if (ret != 0) {
goto error;
}
goto error;
}
- ret = channel_ust_create(usess, domain, attr);
+ ret = channel_ust_create(usess, attr, usess->buffer_type);
if (ret != LTTNG_OK) {
free(attr);
goto error;
/*
* Command LTTNG_ENABLE_EVENT processed by the client thread.
*/
-int cmd_enable_event(struct ltt_session *session, int domain,
+int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
char *channel_name, struct lttng_event *event,
struct lttng_filter_bytecode *filter, int wpipe)
{
rcu_read_lock();
- switch (domain) {
+ switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{
struct ltt_kernel_channel *kchan;
kchan = trace_kernel_get_channel_by_name(channel_name,
session->kernel_session);
if (kchan == NULL) {
- attr = channel_new_default_attr(domain);
+ attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL);
if (attr == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
channel_name);
if (uchan == NULL) {
/* Create default channel */
- attr = channel_new_default_attr(domain);
+ attr = channel_new_default_attr(LTTNG_DOMAIN_UST);
if (attr == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
}
/* At this point, the session and channel exist on the tracer */
- ret = event_ust_enable_tracepoint(usess, domain, uchan, event, filter);
+ ret = event_ust_enable_tracepoint(usess, uchan, event, filter);
if (ret != LTTNG_OK) {
goto error;
}
/*
* Command LTTNG_ENABLE_ALL_EVENT processed by the client thread.
*/
-int cmd_enable_event_all(struct ltt_session *session, int domain,
- char *channel_name, int event_type,
+int cmd_enable_event_all(struct ltt_session *session,
+ struct lttng_domain *domain, char *channel_name, int event_type,
struct lttng_filter_bytecode *filter, int wpipe)
{
int ret;
rcu_read_lock();
- switch (domain) {
+ switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{
struct ltt_kernel_channel *kchan;
session->kernel_session);
if (kchan == NULL) {
/* Create default channel */
- attr = channel_new_default_attr(domain);
+ attr = channel_new_default_attr(LTTNG_DOMAIN_KERNEL);
if (attr == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
channel_name);
if (uchan == NULL) {
/* Create default channel */
- attr = channel_new_default_attr(domain);
+ attr = channel_new_default_attr(LTTNG_DOMAIN_UST);
if (attr == NULL) {
ret = LTTNG_ERR_FATAL;
goto error;
switch (event_type) {
case LTTNG_EVENT_ALL:
case LTTNG_EVENT_TRACEPOINT:
- ret = event_ust_enable_all_tracepoints(usess, domain, uchan,
- filter);
+ ret = event_ust_enable_all_tracepoints(usess, uchan, filter);
if (ret != LTTNG_OK) {
goto error;
}
void cmd_init(void)
{
/*
- * Set network sequence index to 1 for streams to match a relayd socket on
- * the consumer side.
+ * Set network sequence index to 1 for streams to match a relayd
+ * socket on the consumer side.
*/
- uatomic_set(&relayd_net_seq_idx, 1);
+ pthread_mutex_lock(&relayd_net_seq_idx_lock);
+ relayd_net_seq_idx = 1;
+ pthread_mutex_unlock(&relayd_net_seq_idx_lock);
DBG("Command subsystem initialized");
}