}
/*
- * 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.
}
}
+ /*
+ * 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:
/* 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.