*/
static struct ltt_session_list *session_list_ptr;
+int ust_consumer_fd;
+
/*
* Create a poll set with O_CLOEXEC and add the thread quit pipe to the set.
*/
*/
static void teardown_ust_session(struct ltt_session *session)
{
+ int ret;
+
DBG("Tearing down UST session(s)");
+ ret = ust_app_destroy_trace_all(session->ust_session);
+ if (ret) {
+ ERR("Error in ust_app_destroy_trace_all");
+ }
trace_ust_destroy_session(session->ust_session);
}
buf_size = size;
- cmd_ctx->llm = malloc(sizeof(struct lttcomm_lttng_msg) + buf_size);
+ cmd_ctx->llm = zmalloc(sizeof(struct lttcomm_lttng_msg) + buf_size);
if (cmd_ctx->llm == NULL) {
- perror("malloc");
+ perror("zmalloc");
ret = -ENOMEM;
goto error;
}
/* Register applicaton to the session daemon */
ret = ust_app_register(&ust_cmd.reg_msg,
ust_cmd.sock);
- if (ret < 0) {
- /* Only critical ENOMEM error can be returned here */
+ if (ret == -ENOMEM) {
goto error;
+ } else if (ret < 0) {
+ break;
}
/*
goto error;
}
- /* Socket closed */
+ /* Socket closed on remote end. */
ust_app_unregister(pollfd);
break;
}
}
/* Create UST registration command for enqueuing */
- ust_cmd = malloc(sizeof(struct ust_command));
+ ust_cmd = zmalloc(sizeof(struct ust_command));
if (ust_cmd == NULL) {
- perror("ust command malloc");
+ perror("ust command zmalloc");
goto error;
}
sessions[i].path[PATH_MAX - 1] = '\0';
strncpy(sessions[i].name, session->name, NAME_MAX);
sessions[i].name[NAME_MAX - 1] = '\0';
+ sessions[i].enabled = session->enabled;
i++;
}
}
cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) {
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;
switch (uevent->attr.instrumentation) {
case LTTNG_UST_TRACEPOINT:
tmp[i].type = LTTNG_EVENT_TRACEPOINT;
int ret;
struct ltt_ust_session *usess = session->ust_session;
- DBG("Enabling channel %s for session %s", session->name, attr->name);
+ DBG("Enabling channel %s for session %s", attr->name, session->name);
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
ret = LTTCOMM_UST_CHAN_FAIL;
goto error;
}
+
rcu_read_lock();
hashtable_add_unique(usess->domain_global.channels, &uchan->node);
rcu_read_unlock();
}
/* Add channel to all registered applications */
- ret = ust_app_add_channel_all(usess, uchan);
- if (ret != LTTCOMM_OK) {
+ ret = ust_app_create_channel_all(usess, uchan);
+ if (ret != 0) {
goto error;
}
+ uchan->enabled = 1;
+
break;
}
case LTTNG_DOMAIN_UST_PID:
ret = LTTCOMM_FATAL;
goto error;
}
+
}
- ret = ust_app_add_event_all(usess, uchan, uevent);
+ ret = ust_app_create_event_all(usess, uchan, uevent);
if (ret < 0) {
ret = LTTCOMM_UST_ENABLE_FAIL;
goto error;
}
+ /* Add ltt ust event to channel */
rcu_read_lock();
hashtable_add_unique(uchan->events, &uevent->node);
rcu_read_unlock();
+
+ uevent->enabled = 1;
+
+ DBG3("UST ltt event %s added to channel %s", uevent->attr.name,
+ uchan->name);
break;
}
case LTTNG_DOMAIN_UST_EXEC_NAME:
{
int ret;
struct ltt_kernel_session *ksession;
- struct ltt_ust_session *usess = session->ust_session;
+ struct ltt_ust_session *usess;
/* Short cut */
ksession = session->kernel_session;
+ usess = session->ust_session;
+
+ if (session->enabled)
+ return LTTCOMM_UST_START_FAIL;
+ session->enabled = 1;
/* Kernel tracing */
if (ksession != NULL) {
}
/* Flag session that trace should start automatically */
- usess->start_trace = 1;
+ if (usess) {
+ usess->start_trace = 1;
- ret = ust_app_start_trace_all(usess);
- if (ret < 0) {
- ret = LTTCOMM_UST_START_FAIL;
- goto error;
+ ret = ust_app_start_trace_all(usess);
+ if (ret < 0) {
+ ret = LTTCOMM_UST_START_FAIL;
+ goto error;
+ }
}
ret = LTTCOMM_OK;
int ret;
struct ltt_kernel_channel *kchan;
struct ltt_kernel_session *ksession;
- //struct ltt_ust_session *usess;
- //struct ltt_ust_channel *ustchan;
+ struct ltt_ust_session *usess;
/* Short cut */
ksession = session->kernel_session;
+ usess = session->ust_session;
+
+ if (!session->enabled)
+ return LTTCOMM_UST_START_FAIL;
+ session->enabled = 0;
/* Kernel tracer */
if (ksession != NULL) {
kernel_wait_quiescent(kernel_tracer_fd);
}
-#ifdef DISABLE
- /* Stop each UST session */
- DBG("Stop UST tracing");
- cds_list_for_each_entry(usess, &session->ust_session_list.head, list) {
- /* Flush all buffers before stopping */
- ret = ustctl_flush_buffer(usess->sock, usess->metadata->obj);
- if (ret < 0) {
- ERR("UST metadata flush failed");
- }
-
- cds_list_for_each_entry(ustchan, &usess->channels.head, list) {
- ret = ustctl_flush_buffer(usess->sock, ustchan->obj);
- if (ret < 0) {
- ERR("UST flush buffer error");
- }
- }
+ /* Flag session that trace should start automatically */
+ if (usess) {
+ usess->start_trace = 0;
- ret = ustctl_stop_session(usess->sock, usess->handle);
+ ret = ust_app_stop_trace_all(usess);
if (ret < 0) {
- ret = LTTCOMM_KERN_STOP_FAIL;
+ ret = LTTCOMM_UST_START_FAIL;
goto error;
}
-
- ustctl_wait_quiescent(usess->sock);
}
-#endif
ret = LTTCOMM_OK;
/* Clean kernel session teardown */
teardown_kernel_session(session);
+ /* UST session teardown */
+ teardown_ust_session(session);
/*
* Must notify the kernel thread here to update it's poll setin order
if (session->kernel_session != NULL) {
nb_chan = session->kernel_session->channel_count;
}
- DBG3("Number of kernel channels %ld", nb_chan);
+ DBG3("Number of kernel channels %zd", nb_chan);
break;
case LTTNG_DOMAIN_UST:
if (session->ust_session != NULL) {
nb_chan = hashtable_get_count(
session->ust_session->domain_global.channels);
}
- DBG3("Number of UST global channels %ld", nb_chan);
+ DBG3("Number of UST global channels %zd", nb_chan);
break;
default:
*channels = NULL;
goto error;
}
- cmd_ctx->session->ust_session->consumer_fd =
- ustconsumer_data.cmd_sock;
+ ust_consumer_fd = ustconsumer_data.cmd_sock;
}
pthread_mutex_unlock(&ustconsumer_data.pid_mutex);
}
}
/* Allocate context command to process the client request */
- cmd_ctx = malloc(sizeof(struct command_ctx));
+ cmd_ctx = zmalloc(sizeof(struct command_ctx));
if (cmd_ctx == NULL) {
- perror("malloc cmd_ctx");
+ perror("zmalloc cmd_ctx");
goto error;
}
/* Allocate data buffer for reception */
- cmd_ctx->lsm = malloc(sizeof(struct lttcomm_session_msg));
+ cmd_ctx->lsm = zmalloc(sizeof(struct lttcomm_session_msg));
if (cmd_ctx->lsm == NULL) {
- perror("malloc cmd_ctx->lsm");
+ perror("zmalloc cmd_ctx->lsm");
goto error;
}
if (ret < 0) {
/*
* TODO: Inform client somehow of the fatal error. At
- * this point, ret < 0 means that a malloc failed
+ * this point, ret < 0 means that a zmalloc failed
* (ENOMEM). Error detected but still accept command.
*/
clean_command_ctx(&cmd_ctx);