X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Frotation-thread.c;h=25dbf76a932c3414f294848f2211a42e5e8659e3;hp=c0d1cf146d3b69bbe5fcef59c8cf6d076df8752d;hb=a7333da73c2083281c5ec833d041b7acf0d10d0b;hpb=03732c3281c0cfbfd5f1a6b7723c577cab43bab3 diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index c0d1cf146..25dbf76a9 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -72,7 +72,6 @@ struct rotation_thread_timer_queue { }; struct rotation_thread_handle { - int quit_pipe; struct rotation_thread_timer_queue *rotation_timer_queue; /* Access to the notification thread cmd_queue */ struct notification_thread_handle *notification_thread_handle; @@ -169,7 +168,6 @@ void rotation_thread_handle_destroy( } struct rotation_thread_handle *rotation_thread_handle_create( - int quit_pipe, struct rotation_thread_timer_queue *rotation_timer_queue, struct notification_thread_handle *notification_thread_handle, sem_t *notification_thread_ready) @@ -181,7 +179,6 @@ struct rotation_thread_handle *rotation_thread_handle_create( goto end; } - handle->quit_pipe = quit_pipe; handle->rotation_timer_queue = rotation_timer_queue; handle->notification_thread_handle = notification_thread_handle; handle->notification_thread_ready = notification_thread_ready; @@ -276,15 +273,8 @@ int init_poll_set(struct lttng_poll_event *poll_set, * - quit pipe, * - rotation thread timer queue pipe, */ - ret = lttng_poll_create(poll_set, 2, LTTNG_CLOEXEC); - if (ret < 0) { - goto end; - } - - ret = lttng_poll_add(poll_set, handle->quit_pipe, - LPOLLIN | LPOLLERR); - if (ret < 0) { - ERR("[rotation-thread] Failed to add quit_pipe fd to pollset"); + ret = sessiond_set_thread_pollset(poll_set, 2); + if (ret) { goto error; } ret = lttng_poll_add(poll_set, @@ -295,7 +285,6 @@ int init_poll_set(struct lttng_poll_event *poll_set, goto error; } -end: return ret; error: lttng_poll_clean(poll_set); @@ -598,6 +587,44 @@ int check_session_rotation_pending(struct ltt_session *session, session->name); } + if (!session->active) { + /* + * A stop command was issued during the rotation, it is + * up to the rotation completion check to perform the + * renaming of the last chunk that was produced. + */ + ret = notification_thread_command_session_rotation_ongoing( + notification_thread_handle, + session->name, + session->uid, + session->gid, + session->current_archive_id); + if (ret != LTTNG_OK) { + ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s", + session->name); + } + + ret = rename_active_chunk(session); + if (ret < 0) { + ERR("[rotation-thread] Failed to rename active rotation chunk"); + goto end; + } + + /* Ownership of location is transferred. */ + location = session_get_trace_archive_location(session); + ret = notification_thread_command_session_rotation_completed( + notification_thread_handle, + session->name, + session->uid, + session->gid, + session->current_archive_id, + location); + if (ret != LTTNG_OK) { + ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s", + session->name); + } + } + ret = 0; end: if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING) { @@ -777,7 +804,7 @@ int handle_condition(const struct lttng_condition *condition, ret = unsubscribe_session_consumed_size_rotation(session, notification_thread_handle); if (ret) { - goto end; + goto end_unlock; } ret = cmd_rotate_session(session, NULL); @@ -884,7 +911,7 @@ void *thread_rotation(void *data) ret = init_thread_state(handle, &thread); if (ret) { - goto end; + goto error; } /* Ready to handle client connections. */ @@ -922,7 +949,7 @@ void *thread_rotation(void *data) goto error; } - if (fd == handle->quit_pipe) { + if (sessiond_check_thread_quit_pipe(fd, revents)) { DBG("[rotation-thread] Quit pipe activity"); /* TODO flush the queue. */ goto exit;