#include <lttng/trigger/trigger-internal.h>
#include <lttng/condition/condition.h>
#include <lttng/action/action.h>
+#include <lttng/channel.h>
#include <lttng/channel-internal.h>
#include <common/string-utils/string-utils.h>
goto end;
}
- ret = consumer_get_discarded_events(session->id, kchan->fd,
+ ret = consumer_get_discarded_events(session->id, kchan->key,
session->kernel_session->consumer,
discarded_events);
if (ret < 0) {
goto end;
}
- ret = consumer_get_lost_packets(session->id, kchan->fd,
+ ret = consumer_get_lost_packets(session->id, kchan->key,
session->kernel_session->consumer,
lost_packets);
if (ret < 0) {
/*
* Fill lttng_channel array of all channels.
*/
-static void list_lttng_channels(enum lttng_domain_type domain,
+static ssize_t list_lttng_channels(enum lttng_domain_type domain,
struct ltt_session *session, struct lttng_channel *channels,
struct lttng_channel_extended *chan_exts)
{
- int i = 0, ret;
+ int i = 0, ret = 0;
struct ltt_kernel_channel *kchan;
DBG("Listing channels for session %s", session->name);
chan_exts[i].lost_packets = lost_packets;
chan_exts[i].monitor_timer_interval =
extended->monitor_timer_interval;
+ chan_exts[i].blocking_timeout = 0;
i++;
}
}
break;
}
+ chan_exts[i].monitor_timer_interval =
+ uchan->monitor_timer_interval;
+ chan_exts[i].blocking_timeout =
+ uchan->attr.u.s.blocking_timeout;
+
ret = get_ust_runtime_stats(session, uchan,
&discarded_events, &lost_packets);
if (ret < 0) {
}
chan_exts[i].discarded_events = discarded_events;
chan_exts[i].lost_packets = lost_packets;
- chan_exts[i].monitor_timer_interval =
- uchan->monitor_timer_interval;
i++;
}
rcu_read_unlock();
}
end:
- return;
+ if (ret < 0) {
+ return -LTTNG_ERR_FATAL;
+ } else {
+ return LTTNG_OK;
+ }
}
static void increment_extended_len(const char *filter_expression,
/* Check relayd version */
ret = relayd_version_check(rsock);
- if (ret < 0) {
- ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
+ if (ret == LTTNG_ERR_RELAYD_VERSION_FAIL) {
+ goto close_sock;
+ } else if (ret < 0) {
+ ERR("Unable to reach lttng-relayd");
+ ret = LTTNG_ERR_RELAYD_CONNECT_FAIL;
goto close_sock;
}
consumer->relay_major_version = rsock->major;
/*
* Connect to the relayd using URI and send the socket to the right consumer.
+ *
+ * The consumer socket lock must be held by the caller.
*/
static int send_consumer_relayd_socket(enum lttng_domain_type domain,
unsigned int session_id, struct lttng_uri *relayd_uri,
/* Connect to relayd and make version check if uri is the control. */
ret = create_connect_relayd(relayd_uri, &rsock, consumer);
if (ret != LTTNG_OK) {
- goto error;
+ goto relayd_comm_error;
}
assert(rsock);
*/
close_sock:
- (void) relayd_close(rsock);
- free(rsock);
-
-error:
if (ret != LTTNG_OK) {
/*
* The consumer output for this session should not be used anymore
*/
consumer->enabled = 0;
}
+ (void) relayd_close(rsock);
+ free(rsock);
+
+relayd_comm_error:
return ret;
}
* Send both relayd sockets to a specific consumer and domain. This is a
* helper function to facilitate sending the information to the consumer for a
* session.
+ *
+ * The consumer socket lock must be held by the caller.
*/
static int send_consumer_relayd_sockets(enum lttng_domain_type domain,
unsigned int session_id, struct consumer_output *consumer,
attr->attr.switch_timer_interval = 0;
}
+ /* Check for feature support */
+ switch (domain->type) {
+ case LTTNG_DOMAIN_KERNEL:
+ {
+ if (kernel_supports_ring_buffer_snapshot_sample_positions(kernel_tracer_fd) != 1) {
+ /* Sampling position of buffer is not supported */
+ WARN("Kernel tracer does not support buffer monitoring. "
+ "Setting the monitor interval timer to 0 "
+ "(disabled) for channel '%s' of session '%s'",
+ attr-> name, session->name);
+ lttng_channel_set_monitor_timer_interval(attr, 0);
+ }
+ break;
+ }
+ case LTTNG_DOMAIN_UST:
+ case LTTNG_DOMAIN_JUL:
+ case LTTNG_DOMAIN_LOG4J:
+ case LTTNG_DOMAIN_PYTHON:
+ break;
+ default:
+ ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+ goto error;
+ }
+
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{
int ret, chan_kern_created = 0, chan_ust_created = 0;
char *app_ctx_provider_name = NULL, *app_ctx_name = NULL;
+ /*
+ * Don't try to add a context if the session has been started at
+ * some point in time before. The tracer does not allow it and would
+ * result in a corrupted trace.
+ */
+ if (session->has_been_started) {
+ ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
+ goto end;
+ }
+
if (ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT) {
app_ctx_provider_name = ctx->u.app_ctx.provider_name;
app_ctx_name = ctx->u.app_ctx.ctx_name;
channel_exts = ((void *) *channels) +
(nb_chan * sizeof(struct lttng_channel));
- list_lttng_channels(domain, session, *channels, channel_exts);
+ ret = list_lttng_channels(domain, session, *channels, channel_exts);
+ if (ret != LTTNG_OK) {
+ free(*channels);
+ *channels = NULL;
+ goto end;
+ }
} else {
*channels = NULL;
}
ret = LTTNG_ERR_SESSION_NOT_STARTED;
goto end;
}
- ret = 0;
if (session->kernel_session) {
ret = kernctl_session_regenerate_statedump(
rcu_read_lock();
cds_lfht_for_each_entry(snap_output->consumer->socks->ht, &iter.iter,
socket, node.node) {
+ pthread_mutex_lock(socket->lock);
ret = send_consumer_relayd_sockets(0, session->id,
snap_output->consumer, socket,
session->name, session->hostname,
session->live_timer);
+ pthread_mutex_unlock(socket->lock);
if (ret != LTTNG_OK) {
rcu_read_unlock();
goto error;