Bug #433 » 0001-Fix-add-health-state-update.patch
src/bin/lttng-sessiond/cmd.c | ||
---|---|---|
if (session->kernel_session != NULL) {
|
||
cds_list_for_each_entry(kchan,
|
||
&session->kernel_session->channel_list.head, list) {
|
||
health_code_update();
|
||
/* Copy lttng_channel struct to array */
|
||
memcpy(&channels[i], kchan->channel, sizeof(struct lttng_channel));
|
||
channels[i].enabled = kchan->enabled;
|
||
... | ... | |
rcu_read_lock();
|
||
cds_lfht_for_each_entry(session->ust_session->domain_global.channels->ht,
|
||
&iter.iter, uchan, node.node) {
|
||
health_code_update();
|
||
strncpy(channels[i].name, uchan->name, LTTNG_SYMBOL_NAME_LEN);
|
||
channels[i].attr.overwrite = uchan->attr.overwrite;
|
||
channels[i].attr.subbuf_size = uchan->attr.subbuf_size;
|
||
... | ... | |
}
|
||
cds_lfht_for_each_entry(uchan->events->ht, &iter.iter, uevent, node.node) {
|
||
health_code_update();
|
||
strncpy(tmp[i].name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN);
|
||
tmp[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
|
||
tmp[i].enabled = uevent->enabled;
|
||
... | ... | |
/* Kernel channels */
|
||
cds_list_for_each_entry(event, &kchan->events_list.head , list) {
|
||
health_code_update();
|
||
strncpy((*events)[i].name, event->event->name, LTTNG_SYMBOL_NAME_LEN);
|
||
(*events)[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
|
||
(*events)[i].enabled = event->enabled;
|
||
... | ... | |
assert(uri);
|
||
health_code_update();
|
||
if (consumer == NULL) {
|
||
DBG("No consumer detected. Don't add URI. Stopping.");
|
||
ret = LTTNG_ERR_NO_CONSUMER;
|
||
... | ... | |
}
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
struct lttcomm_sock *sock;
|
||
health_code_update();
|
||
/* Create socket object from URI */
|
||
sock = lttcomm_alloc_sock_from_uri(uri);
|
||
if (sock == NULL) {
|
||
... | ... | |
}
|
||
/* Connect to relayd so we can proceed with a session creation. */
|
||
health_poll_entry();
|
||
ret = relayd_connect(sock);
|
||
health_poll_exit();
|
||
if (ret < 0) {
|
||
ERR("Unable to reach lttng-relayd");
|
||
ret = LTTNG_ERR_RELAYD_CONNECT_FAIL;
|
||
... | ... | |
DBG3("Creating relayd stream socket from URI");
|
||
/* Check relayd version */
|
||
health_poll_entry();
|
||
ret = relayd_version_check(sock, RELAYD_VERSION_COMM_MAJOR,
|
||
RELAYD_VERSION_COMM_MINOR);
|
||
health_poll_exit();
|
||
if (ret < 0) {
|
||
ret = LTTNG_ERR_RELAYD_VERSION_FAIL;
|
||
goto close_sock;
|
||
... | ... | |
*relayd_sock = sock;
|
||
health_code_update();
|
||
return LTTNG_OK;
|
||
close_sock:
|
||
... | ... | |
lttcomm_destroy_sock(sock);
|
||
}
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
struct lttcomm_sock *sock = NULL;
|
||
health_code_update();
|
||
/* Set the network sequence index if not set. */
|
||
if (consumer->net_seq_index == -1) {
|
||
/*
|
||
... | ... | |
lttcomm_destroy_sock(sock);
|
||
}
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
/* Code flow error */
|
||
assert(socket->fd >= 0);
|
||
health_poll_entry();
|
||
pthread_mutex_lock(socket->lock);
|
||
health_poll_exit();
|
||
ret = send_consumer_relayd_sockets(LTTNG_DOMAIN_UST, session,
|
||
usess->consumer, socket);
|
||
pthread_mutex_unlock(socket->lock);
|
||
... | ... | |
/* Code flow error */
|
||
assert(socket->fd >= 0);
|
||
health_poll_entry();
|
||
pthread_mutex_lock(socket->lock);
|
||
health_poll_exit();
|
||
ret = send_consumer_relayd_sockets(LTTNG_DOMAIN_KERNEL, session,
|
||
ksess->consumer, socket);
|
||
pthread_mutex_unlock(socket->lock);
|
||
... | ... | |
int ret;
|
||
struct ltt_kernel_channel *kchan;
|
||
health_code_update();
|
||
/* Open kernel metadata */
|
||
if (ksess->metadata == NULL) {
|
||
ret = kernel_open_metadata(ksess);
|
||
... | ... | |
/* For each channel */
|
||
cds_list_for_each_entry(kchan, &ksess->channel_list.head, list) {
|
||
health_code_update();
|
||
if (kchan->stream_count == 0) {
|
||
ret = kernel_open_channel_stream(kchan);
|
||
if (ret < 0) {
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
usess = session->ust_session;
|
||
rcu_read_lock();
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
rcu_read_unlock();
|
||
return ret;
|
||
}
|
||
... | ... | |
DBG("Enabling channel %s for session %s", attr->name, session->name);
|
||
rcu_read_lock();
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
... | ... | |
}
|
||
error:
|
||
health_code_update();
|
||
rcu_read_unlock();
|
||
return ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
rcu_read_lock();
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
rcu_read_unlock();
|
||
return ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
rcu_read_lock();
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
rcu_read_unlock();
|
||
return ret;
|
||
}
|
||
... | ... | |
{
|
||
int ret;
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
assert(session->kernel_session);
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(channel_name);
|
||
rcu_read_lock();
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
rcu_read_unlock();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(channel_name);
|
||
rcu_read_lock();
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
rcu_read_unlock();
|
||
return ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
ssize_t nb_events = 0;
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
nb_events = kernel_list_events(kernel_tracer_fd, events);
|
||
... | ... | |
goto error;
|
||
}
|
||
health_code_update();
|
||
return nb_events;
|
||
error:
|
||
health_code_update();
|
||
/* Return negative value to differentiate return code */
|
||
return -ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
ssize_t nb_fields = 0;
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_UST:
|
||
nb_fields = ust_app_list_event_fields(fields);
|
||
... | ... | |
goto error;
|
||
}
|
||
health_code_update();
|
||
return nb_fields;
|
||
error:
|
||
health_code_update();
|
||
/* Return negative value to differentiate return code */
|
||
return -ret;
|
||
}
|
||
... | ... | |
assert(session);
|
||
health_code_update();
|
||
/* Ease our life a bit ;) */
|
||
ksession = session->kernel_session;
|
||
usess = session->ust_session;
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(session);
|
||
health_code_update();
|
||
/* Short cut */
|
||
ksession = session->kernel_session;
|
||
usess = session->ust_session;
|
||
... | ... | |
/* Flush all buffers before stopping */
|
||
cds_list_for_each_entry(kchan, &ksession->channel_list.head, list) {
|
||
health_code_update();
|
||
ret = kernel_flush_buffer(kchan);
|
||
if (ret < 0) {
|
||
ERR("Kernel flush buffer error");
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(uris);
|
||
assert(nb_uri > 0);
|
||
health_code_update();
|
||
/* Can't enable consumer after session started. */
|
||
if (session->enabled) {
|
||
ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(name);
|
||
health_code_update();
|
||
/*
|
||
* Verify if the session already exist
|
||
*
|
||
... | ... | |
session->consumer->enabled = 1;
|
||
end:
|
||
health_code_update();
|
||
return LTTNG_OK;
|
||
consumer_error:
|
||
session_destroy(session);
|
||
session_error:
|
||
find_error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
/* Safety net */
|
||
assert(session);
|
||
health_code_update();
|
||
usess = session->ust_session;
|
||
ksess = session->kernel_session;
|
||
... | ... | |
ret = session_destroy(session);
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
{
|
||
int ret;
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
{
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(cdata);
|
||
assert(sock_path);
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
{
|
||
... | ... | |
goto error;
|
||
}
|
||
health_poll_entry();
|
||
sock = lttcomm_connect_unix_sock(sock_path);
|
||
health_poll_exit();
|
||
if (sock < 0) {
|
||
ret = LTTNG_ERR_CONNECT_FAIL;
|
||
goto error;
|
||
... | ... | |
ret = LTTNG_OK;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
int ret, index = 0;
|
||
ssize_t nb_dom = 0;
|
||
health_code_update();
|
||
if (session->kernel_session != NULL) {
|
||
DBG3("Listing domains found kernel domain");
|
||
nb_dom++;
|
||
... | ... | |
index++;
|
||
}
|
||
health_code_update();
|
||
return nb_dom;
|
||
error:
|
||
health_code_update();
|
||
/* Return negative value to differentiate return code */
|
||
return -ret;
|
||
}
|
||
... | ... | |
int ret;
|
||
ssize_t nb_chan = 0;
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
if (session->kernel_session != NULL) {
|
||
... | ... | |
goto error;
|
||
}
|
||
health_code_update();
|
||
return nb_chan;
|
||
error:
|
||
health_code_update();
|
||
/* Return negative value to differentiate return code */
|
||
return -ret;
|
||
}
|
||
... | ... | |
int ret = 0;
|
||
ssize_t nb_event = 0;
|
||
health_code_update();
|
||
switch (domain) {
|
||
case LTTNG_DOMAIN_KERNEL:
|
||
if (session->kernel_session != NULL) {
|
||
... | ... | |
goto error;
|
||
}
|
||
health_code_update();
|
||
return nb_event;
|
||
error:
|
||
health_code_update();
|
||
/* Return negative value to differentiate return code */
|
||
return -ret;
|
||
}
|
||
... | ... | |
DBG("Getting all available session for UID %d GID %d",
|
||
uid, gid);
|
||
health_code_update();
|
||
/*
|
||
* Iterate over session list and append data after the control struct in
|
||
* the buffer.
|
||
*/
|
||
cds_list_for_each_entry(session, &list->head, list) {
|
||
health_code_update();
|
||
/*
|
||
* Only list the sessions the user can control.
|
||
*/
|
||
... | ... | |
assert(session);
|
||
health_code_update();
|
||
if (session->enabled) {
|
||
/* Can't disable consumer on an already started session */
|
||
ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
|
||
... | ... | |
}
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(session);
|
||
health_code_update();
|
||
/* Can't enable consumer after session started. */
|
||
if (session->enabled) {
|
||
ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
|
||
... | ... | |
}
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
assert(session);
|
||
health_code_update();
|
||
/* Session MUST be stopped to ask for data availability. */
|
||
if (session->enabled) {
|
||
ret = LTTNG_ERR_SESSION_STARTED;
|
||
... | ... | |
ret = 0;
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
src/bin/lttng-sessiond/consumer.c | ||
---|---|---|
assert(sock);
|
||
health_poll_entry();
|
||
ret = lttcomm_recv_unix_sock(sock->fd, &reply, sizeof(reply));
|
||
health_poll_exit();
|
||
if (ret <= 0) {
|
||
if (ret == 0) {
|
||
/* Orderly shutdown. Don't return 0 which means success. */
|
||
... | ... | |
assert(consumer);
|
||
assert(consumer_sock);
|
||
health_code_update();
|
||
/* Bail out if consumer is disabled */
|
||
if (!consumer->enabled) {
|
||
ret = LTTNG_OK;
|
||
... | ... | |
DBG2("Consumer relayd socket sent");
|
||
error:
|
||
health_code_update();
|
||
return ret;
|
||
}
|
||
... | ... | |
* the reply status message.
|
||
*/
|
||
health_poll_entry();
|
||
ret = lttcomm_recv_unix_sock(socket->fd, &ret_code, sizeof(ret_code));
|
||
health_poll_exit();
|
||
if (ret <= 0) {
|
||
if (ret == 0) {
|
||
/* Orderly shutdown. Don't return 0 which means success. */
|
src/bin/lttng-sessiond/main.c | ||
---|---|---|
goto error;
|
||
}
|
||
health_poll_entry();
|
||
pthread_mutex_lock(&consumer_data->pid_mutex);
|
||
health_poll_exit();
|
||
if (consumer_data->pid != 0) {
|
||
pthread_mutex_unlock(&consumer_data->pid_mutex);
|
||
goto end;
|
||
... | ... | |
goto error;
|
||
}
|
||
health_code_update();
|
||
/* Setting up the consumer_data pid */
|
||
consumer_data->pid = ret;
|
||
DBG2("Consumer pid %d", consumer_data->pid);
|
||
... | ... | |
goto error;
|
||
}
|
||
health_code_update();
|
||
end:
|
||
return 0;
|
||
... | ... | |
/* Create directory(ies) on local filesystem. */
|
||
if (session->kernel_session->consumer->type == CONSUMER_DST_LOCAL &&
|
||
strlen(session->kernel_session->consumer->dst.trace_path) > 0) {
|
||
health_code_update();
|
||
ret = run_as_mkdir_recursive(
|
||
session->kernel_session->consumer->dst.trace_path,
|
||
S_IRWXU | S_IRWXG, session->uid, session->gid);
|
||
... | ... | |
}
|
||
skip_domain:
|
||
health_code_update();
|
||
/* Validate consumer daemon state when start/stop trace command */
|
||
if (cmd_ctx->lsm->cmd_type == LTTNG_START_TRACE ||
|
||
cmd_ctx->lsm->cmd_type == LTTNG_STOP_TRACE) {
|
||
... | ... | |
/* Receive variable len data */
|
||
DBG("Receiving %zu URI(s) from client ...", nb_uri);
|
||
health_poll_entry();
|
||
ret = lttcomm_recv_unix_sock(sock, uris, len);
|
||
health_poll_exit();
|
||
if (ret <= 0) {
|
||
DBG("No URIs received from client... continuing");
|
||
*sock_error = 1;
|
||
... | ... | |
/* Receive variable len data */
|
||
DBG("Waiting for %zu URIs from client ...", nb_uri);
|
||
health_poll_entry();
|
||
ret = lttcomm_recv_unix_sock(sock, uris, len);
|
||
health_poll_exit();
|
||
if (ret <= 0) {
|
||
DBG("No URIs received from client... continuing");
|
||
*sock_error = 1;
|
||
... | ... | |
}
|
||
/* Receive var. len. data */
|
||
DBG("Receiving var len data from client ...");
|
||
health_poll_entry();
|
||
ret = lttcomm_recv_unix_sock(sock, bytecode,
|
||
cmd_ctx->lsm->u.enable.bytecode_len);
|
||
health_poll_exit();
|
||
if (ret <= 0) {
|
||
DBG("Nothing recv() from client var len data... continuing");
|
||
*sock_error = 1;
|
src/bin/lttng-sessiond/session.c | ||
---|---|---|
#include <common/common.h>
|
||
#include <common/sessiond-comm/sessiond-comm.h>
|
||
#include "health.h"
|
||
#include "session.h"
|
||
/*
|
||
... | ... | |
*/
|
||
void session_lock_list(void)
|
||
{
|
||
/*
|
||
* Trying to lock this session list can take an arbitrary amount of time so
|
||
* let's set the health poll execution state.
|
||
*/
|
||
health_poll_entry();
|
||
pthread_mutex_lock(<t_session_list.lock);
|
||
health_poll_exit();
|
||
}
|
||
/*
|
||
... | ... | |
*/
|
||
void session_lock(struct ltt_session *session)
|
||
{
|
||
/*
|
||
* Trying to lock this session list can take an arbitrary amount of time so
|
||
* let's set the health poll execution state.
|
||
*/
|
||
health_poll_entry();
|
||
pthread_mutex_lock(&session->lock);
|
||
health_poll_exit();
|
||
}
|
||
/*
|
src/bin/lttng-sessiond/ust-consumer.c | ||
---|---|---|
}
|
||
cds_list_for_each_entry_safe(stream, tmp, &uchan->streams.head, list) {
|
||
health_code_update();
|
||
if (!stream->obj->shm_fd) {
|
||
continue;
|
||
}
|
tests/tools/Makefile.am | ||
---|---|---|
UTILS=../utils.h
|
||
SESSIONS=$(top_srcdir)/src/bin/lttng-sessiond/session.c \
|
||
$(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
|
||
$(top_srcdir)/src/bin/lttng-sessiond/health.c \
|
||
$(top_srcdir)/src/common/uri.c \
|
||
$(top_srcdir)/src/common/utils.c \
|
||
$(top_srcdir)/src/common/error.c
|
||
KERN_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-kernel.c \
|
||
$(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
|
||
$(top_srcdir)/src/bin/lttng-sessiond/health.c \
|
||
$(top_srcdir)/src/common/uri.c \
|
||
$(top_srcdir)/src/common/utils.c
|
||
COMMON=$(top_builddir)/src/common/libcommon.la
|
||
COMMON=$(top_builddir)/src/common/libcommon.la -lrt
|
||
HASHTABLE=$(top_builddir)/src/common/hashtable/libhashtable.la
|
||
SESSIOND_COMM=$(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la
|
||
... | ... | |
noinst_PROGRAMS += test_ust_data_trace
|
||
UST_DATA_TRACE=$(top_srcdir)/src/bin/lttng-sessiond/trace-ust.c \
|
||
$(top_srcdir)/src/bin/lttng-sessiond/consumer.c \
|
||
$(top_srcdir)/src/bin/lttng-sessiond/health.c \
|
||
$(top_srcdir)/src/common/uri.c \
|
||
$(top_srcdir)/src/common/utils.c
|
||
# UST trace data unit tests
|