}
/*
- * For each tracing session, update newly registered apps.
+ * For each tracing session, update newly registered apps. The session list
+ * lock MUST be acquired before calling this.
*/
static void update_ust_app(int app_sock)
{
struct ltt_session *sess, *stmp;
- session_lock_list();
-
/* For all tracing session(s) */
cds_list_for_each_entry_safe(sess, stmp, &session_list_ptr->head, list) {
session_lock(sess);
}
session_unlock(sess);
}
-
- session_unlock_list();
}
/*
/* Poll infinite value of time */
restart:
- health_poll_update();
+ health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- health_poll_update();
+ health_poll_exit();
if (ret < 0) {
/*
* Restart interrupted system call.
health_register(HEALTH_TYPE_CONSUMER);
- /*
- * Since the consumer thread can be spawned at any moment in time, we init
- * the health to a poll status (1, which is a valid health over time).
- * When the thread starts, we update here the health to a "code" path being
- * an even value so this thread, when reaching a poll wait, does not
- * trigger an error with an even value.
- *
- * Here is the use case we avoid.
- *
- * +1: the first poll update during initialization (main())
- * +2 * x: multiple code update once in this thread.
- * +1: poll wait in this thread (being a good health state).
- * == even number which after the wait period shows as a bad health.
- *
- * In a nutshell, the following poll update to the health state brings back
- * the state to an even value meaning a code path.
- */
- health_poll_update();
+ health_code_update();
/*
* Pass 2 as size here for the thread quit pipe and kconsumerd_err_sock.
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update();
+ health_poll_entry();
if (testpoint(thread_manage_consumer)) {
goto error;
}
ret = lttng_poll_wait(&events, -1);
- health_poll_update();
+ health_poll_exit();
if (ret < 0) {
/*
* Restart interrupted system call.
/* Inifinite blocking call, waiting for transmission */
restart_poll:
- health_poll_update();
+ health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- health_poll_update();
+ health_poll_exit();
if (ret < 0) {
/*
* Restart interrupted system call.
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update();
+ health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- health_poll_update();
+ health_poll_exit();
if (ret < 0) {
/*
* Restart interrupted system call.
health_code_update();
+ /*
+ * @session_lock
+ * Lock the global session list so from the register up to
+ * the registration done message, no thread can see the
+ * application and change its state.
+ */
+ session_lock_list();
+
/* Register applicaton to the session daemon */
ret = ust_app_register(&ust_cmd.reg_msg,
ust_cmd.sock);
if (ret == -ENOMEM) {
+ session_unlock_list();
goto error;
} else if (ret < 0) {
+ session_unlock_list();
break;
}
ret = lttng_poll_add(&events, ust_cmd.sock,
LPOLLERR & LPOLLHUP & LPOLLRDHUP);
if (ret < 0) {
+ session_unlock_list();
goto error;
}
DBG("Apps with sock %d added to poll set",
ust_cmd.sock);
}
+ session_unlock_list();
health_code_update();
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update();
+ health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- health_poll_update();
+ health_poll_exit();
if (ret < 0) {
/*
* Restart interrupted system call.
/* Start the kernel consumer daemon */
pthread_mutex_lock(&kconsumer_data.pid_mutex);
if (kconsumer_data.pid == 0 &&
- cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER &&
- cmd_ctx->session->start_consumer) {
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
pthread_mutex_unlock(&kconsumer_data.pid_mutex);
ret = start_consumerd(&kconsumer_data);
if (ret < 0) {
pthread_mutex_lock(&ustconsumer64_data.pid_mutex);
if (consumerd64_bin[0] != '\0' &&
ustconsumer64_data.pid == 0 &&
- cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER &&
- cmd_ctx->session->start_consumer) {
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
pthread_mutex_unlock(&ustconsumer64_data.pid_mutex);
ret = start_consumerd(&ustconsumer64_data);
if (ret < 0) {
/* 32-bit */
if (consumerd32_bin[0] != '\0' &&
ustconsumer32_data.pid == 0 &&
- cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER &&
- cmd_ctx->session->start_consumer) {
+ cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
pthread_mutex_unlock(&ustconsumer32_data.pid_mutex);
ret = start_consumerd(&ustconsumer32_data);
if (ret < 0) {
}
}
+ /*
+ * Send relayd information to consumer as soon as we have a domain and a
+ * session defined.
+ */
+ if (cmd_ctx->session && need_domain) {
+ /*
+ * Setup relayd if not done yet. If the relayd information was already
+ * sent to the consumer, this call will gracefully return.
+ */
+ ret = cmd_setup_relayd(cmd_ctx->session);
+ if (ret != LTTNG_OK) {
+ goto error;
+ }
+ }
+
/* Process by command type */
switch (cmd_ctx->lsm->cmd_type) {
case LTTNG_ADD_CONTEXT:
cmd_ctx->lsm->u.disable.channel_name);
break;
}
- case LTTNG_DISABLE_CONSUMER:
- {
- ret = cmd_disable_consumer(cmd_ctx->lsm->domain.type, cmd_ctx->session);
- break;
- }
case LTTNG_ENABLE_CHANNEL:
{
ret = cmd_enable_channel(cmd_ctx->session, cmd_ctx->lsm->domain.type,
&cmd_ctx->lsm->u.channel.chan, kernel_poll_pipe[1]);
break;
}
- case LTTNG_ENABLE_CONSUMER:
- {
- /*
- * XXX: 0 means that this URI should be applied on the session. Should
- * be a DOMAIN enuam.
- */
- ret = cmd_enable_consumer(cmd_ctx->lsm->domain.type, cmd_ctx->session);
- if (ret != LTTNG_OK) {
- goto error;
- }
-
- if (cmd_ctx->lsm->domain.type == 0) {
- /* Add the URI for the UST session if a consumer is present. */
- if (cmd_ctx->session->ust_session &&
- cmd_ctx->session->ust_session->consumer) {
- ret = cmd_enable_consumer(LTTNG_DOMAIN_UST, cmd_ctx->session);
- } else if (cmd_ctx->session->kernel_session &&
- cmd_ctx->session->kernel_session->consumer) {
- ret = cmd_enable_consumer(LTTNG_DOMAIN_KERNEL,
- cmd_ctx->session);
- }
- }
- break;
- }
case LTTNG_ENABLE_EVENT:
{
ret = cmd_enable_event(cmd_ctx->session, cmd_ctx->lsm->domain.type,
/* Inifinite blocking call, waiting for transmission */
restart:
- health_poll_update();
+ health_poll_entry();
ret = lttng_poll_wait(&events, -1);
- health_poll_update();
+ health_poll_exit();
if (ret < 0) {
/*
* Restart interrupted system call.