*/
utils_close_pipe(thread_quit_pipe);
- /*
- * If config.pid_file_path.value is undefined, the default file will be
- * wiped when removing the rundir.
- */
- if (config.pid_file_path.value) {
- ret = remove(config.pid_file_path.value);
- if (ret < 0) {
- PERROR("remove pidfile %s", config.pid_file_path.value);
- }
+ ret = remove(config.pid_file_path.value);
+ if (ret < 0) {
+ PERROR("remove pidfile %s", config.pid_file_path.value);
}
DBG("Removing sessiond and consumerd content of directory %s",
*
* Useful for CPU hotplug feature.
*/
-static int update_kernel_stream(struct consumer_data *consumer_data, int fd)
+static int update_kernel_stream(int fd)
{
int ret = 0;
struct ltt_session *session;
* New CPU detected by the kernel. Adding kernel stream to
* kernel session and updating the kernel consumer
*/
- ret = update_kernel_stream(&kconsumer_data, pollfd);
+ ret = update_kernel_stream(pollfd);
if (ret < 0) {
continue;
}
case LTTNG_ROTATION_GET_INFO:
case LTTNG_SESSION_GET_CURRENT_OUTPUT:
case LTTNG_ROTATION_SET_SCHEDULE:
- case LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD:
- case LTTNG_ROTATION_SCHEDULE_GET_SIZE:
+ case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
need_domain = 0;
break;
default:
case LTTNG_DATA_PENDING:
case LTTNG_ROTATE_SESSION:
case LTTNG_ROTATION_GET_INFO:
- case LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD:
- case LTTNG_ROTATION_SCHEDULE_GET_SIZE:
+ case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
break;
default:
/* Setup lttng message with no payload */
}
case LTTNG_ROTATION_SET_SCHEDULE:
{
+ bool set_schedule;
+ enum lttng_rotation_schedule_type schedule_type;
+ uint64_t value;
+
if (cmd_ctx->session->kernel_session && !check_rotate_compatible()) {
DBG("Kernel tracer version does not support session rotations");
ret = LTTNG_ERR_ROTATION_WRONG_VERSION;
goto error;
}
+ set_schedule = cmd_ctx->lsm->u.rotation_set_schedule.set == 1;
+ schedule_type = (enum lttng_rotation_schedule_type) cmd_ctx->lsm->u.rotation_set_schedule.type;
+ value = cmd_ctx->lsm->u.rotation_set_schedule.value;
+
ret = cmd_rotation_set_schedule(cmd_ctx->session,
- cmd_ctx->lsm->u.rotate_setup.timer_us,
- cmd_ctx->lsm->u.rotate_setup.size,
+ set_schedule,
+ schedule_type,
+ value,
notification_thread_handle);
if (ret != LTTNG_OK) {
goto error;
break;
}
- case LTTNG_ROTATION_SCHEDULE_GET_TIMER_PERIOD:
- {
- struct lttng_rotation_schedule_get_timer_period *get_timer;
-
- get_timer = zmalloc(sizeof(struct lttng_rotation_schedule_get_timer_period));
- if (!get_timer) {
- ret = ENOMEM;
- goto error;
- }
- get_timer->rotate_timer = cmd_ctx->session->rotate_timer_period;
-
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, get_timer,
- sizeof(struct lttng_rotation_schedule_get_timer_period));
- free(get_timer);
- if (ret < 0) {
- ret = -ret;
- goto error;
- }
-
- ret = LTTNG_OK;
- break;
- }
- case LTTNG_ROTATION_SCHEDULE_GET_SIZE:
+ case LTTNG_SESSION_LIST_ROTATION_SCHEDULES:
{
- struct lttng_rotation_schedule_get_size *get_size;
-
- get_size = zmalloc(sizeof(struct lttng_rotation_schedule_get_size));
- if (!get_size) {
- ret = ENOMEM;
- goto error;
- }
- get_size->rotate_size = cmd_ctx->session->rotate_size;
-
- ret = setup_lttng_msg_no_cmd_header(cmd_ctx, get_size,
- sizeof(struct lttng_rotation_schedule_get_size));
- free(get_size);
+ struct lttng_session_list_schedules_return schedules = {
+ .periodic.set = !!cmd_ctx->session->rotate_timer_period,
+ .periodic.value = cmd_ctx->session->rotate_timer_period,
+ .size.set = !!cmd_ctx->session->rotate_size,
+ .size.value = cmd_ctx->session->rotate_size,
+ };
+
+ ret = setup_lttng_msg_no_cmd_header(cmd_ctx, &schedules,
+ sizeof(schedules));
if (ret < 0) {
ret = -ret;
goto error;
if (ret > 0 || (ret < 0 && errno != EINTR)) {
goto exit;
}
- cmm_smp_rmb();
}
+ /*
+ * This barrier is paired with the one in sessiond_notify_ready() to
+ * ensure that loads accessing data initialized by the other threads,
+ * on which this thread was waiting, are not performed before this point.
+ *
+ * Note that this could be a 'read' memory barrier, but a full barrier
+ * is used in case the code changes. The performance implications of
+ * this choice are minimal since this is a slow path.
+ */
+ cmm_smp_mb();
/* This testpoint is after we signal readiness to the parent. */
if (testpoint(sessiond_thread_manage_clients)) {
health_code_update();
while (1) {
+ const struct cmd_completion_handler *cmd_completion_handler;
+
DBG("Accepting client command ...");
/* Inifinite blocking call, waiting for transmission */
continue;
}
+ cmd_completion_handler = cmd_pop_completion_handler();
+ if (cmd_completion_handler) {
+ enum lttng_error_code completion_code;
+
+ completion_code = cmd_completion_handler->run(
+ cmd_completion_handler->data);
+ if (completion_code != LTTNG_OK) {
+ clean_command_ctx(&cmd_ctx);
+ continue;
+ }
+ }
+
health_code_update();
DBG("Sending response (size: %d, retcode: %s (%d))",
goto exit_set_signal_handler;
}
+ /*
+ * Init config from environment variables.
+ * Command line option override env configuration per-doc. Do env first.
+ */
+ sessiond_config_apply_env_config(&config);
+
/*
* Parse arguments and load the daemon configuration file.
*
goto exit_options;
}
- /* Init config from environment variables. */
- sessiond_config_apply_env_config(&config);
-
/*
* Resolve all paths received as arguments, configuration option, or
* through environment variable as absolute paths. This is necessary