goto error;
}
- if (session->rotate_pending) {
+ if (session->rotate_pending || session->rotate_pending_relay) {
ret = -LTTNG_ERR_ROTATE_PENDING;
goto error;
}
- /*
- * If the user did not wait for the previous rotation to complete
- * (--no-wait), we have to ensure now that the relay had time to
- * receive all the data pending from the previous rotation.
- */
- if (session->rotate_pending_relay) {
- ret = relay_rotate_pending(session,
- session->rotate_count - 1);
- if (ret == 0) {
- DBG("Previous rotation completed on the relay for session %s"
- ", rotate_id %" PRIu64,
- session->name,
- session->rotate_count);
- session->rotate_pending_relay = 0;
- } else if (ret == 1) {
- DBG("Session %s, rotate_id %" PRIu64 " still pending "
- "on the relay",
- session->name, session->rotate_count);
- ret = -LTTNG_ERR_ROTATE_PENDING;
- goto error;
- } else {
- ERR("Failed to check rotate pending on the relay");
- ret = -LTTNG_ERR_UNK;
- }
- }
-
/* Special case for the first rotation. */
if (session->rotate_count == 0) {
const char *base_path = NULL;
(*pending_return)->status = LTTNG_ROTATE_EMPTY;
/* Rotate with a relay */
} else if (session->rotate_pending_relay) {
- /* The consumer has not finished the rotation. */
- if (session->rotate_pending) {
- DBG("Session %s, rotate_id %" PRIu64 " still pending",
- session->name, session->rotate_count);
- (*pending_return)->status = LTTNG_ROTATE_STARTED;
- } else {
- /*
- * The consumer finished the rotation, but we don't
- * know if the relay still has data pending. We need to
- * find one consumer_output to talk to the relay and
- * ask it.
- *
- * (rotate_count - 1) is the chunk id that we want to
- * make sure is completely flushed to disk on the
- * relay.
- */
- ret = relay_rotate_pending(session,
- session->rotate_count - 1);
- if (ret == 0) {
- DBG("Rotate completed on the relay for session %s"
- ", rotate_id %" PRIu64,
- session->name,
- session->rotate_count);
- session->rotate_pending_relay = 0;
- (*pending_return)->status = LTTNG_ROTATE_COMPLETED;
- snprintf((*pending_return)->output_path, PATH_MAX, "%s",
- session->rotation_chunk.current_rotate_path);
- } else if (ret == 1) {
- DBG("Session %s, rotate_id %" PRIu64 " still pending "
- "on the relay",
- session->name, session->rotate_count);
- (*pending_return)->status = LTTNG_ROTATE_STARTED;
- } else {
- ERR("Failed to check rotate pending on the relay");
- (*pending_return)->status = LTTNG_ROTATE_ERROR;
- }
- }
+ DBG("Session %s, rotate_id %" PRIu64 " still pending",
+ session->name, session->rotate_count);
+ (*pending_return)->status = LTTNG_ROTATE_STARTED;
} else if (session->rotate_pending) {
DBG("Session %s, rotate_id %" PRIu64 " still pending",
session->name, session->rotate_count);
struct lttng_pipe *ust32_channel_rotate_pipe = NULL,
*ust64_channel_rotate_pipe = NULL,
*kernel_channel_rotate_pipe = NULL;
+ struct timer_thread_parameters timer_thread_ctx;
init_kernel_workarounds();
retval = -1;
goto exit_init_data;
}
+ /*
+ * The write-side of the pipe is used by the timer thread to wakeup
+ * the rotation thread when needed.
+ */
+ timer_thread_ctx.rotate_timer_pipe = rotate_timer_pipe[1];
/* 64 bits consumerd path setup */
ret = snprintf(ustconsumer64_data.err_unix_sock_path, PATH_MAX,
/* Create timer thread. */
ret = pthread_create(&timer_thread, default_pthread_attr(),
- sessiond_timer_thread, NULL);
+ sessiond_timer_thread, &timer_thread_ctx);
if (ret) {
errno = ret;
PERROR("pthread_create timer");
return 0;
}
+static
+void relay_rotation_pending_timer(struct timer_thread_parameters *ctx,
+ int sig, siginfo_t *si)
+{
+ int ret;
+ struct ltt_session *session = si->si_value.sival_ptr;
+ assert(session);
+
+ ret = lttng_write(ctx->rotate_timer_pipe, &session->id,
+ sizeof(session->id));
+ if (ret < sizeof(session->id)) {
+ PERROR("wakeup rotate pipe");
+ }
+}
+
/*
* This thread is the sighandler for the timer signals.
*/
int signr;
sigset_t mask;
siginfo_t info;
+ struct timer_thread_parameters *ctx = data;
rcu_register_thread();
rcu_thread_online();
fprintf(stderr, "KILL\n");
goto end;
} else if (signr == LTTNG_SESSIOND_SIG_ROTATE_PENDING) {
- fprintf(stderr, "ALLO TIMER\n");
+ fprintf(stderr, "PENDING TIMER\n");
+ relay_rotation_pending_timer(ctx, info.si_signo, &info);
} else {
ERR("Unexpected signal %d\n", info.si_signo);
}