2 * Copyright (C) 2017 - Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2018 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <lttng/trigger/trigger.h>
21 #include <common/error.h>
22 #include <common/config/session-config.h>
23 #include <common/defaults.h>
24 #include <common/utils.h>
25 #include <common/futex.h>
26 #include <common/align.h>
27 #include <common/time.h>
28 #include <common/hashtable/utils.h>
29 #include <sys/eventfd.h>
35 #include <common/kernel-ctl/kernel-ctl.h>
36 #include <lttng/notification/channel-internal.h>
37 #include <lttng/rotate-internal.h>
39 #include "rotation-thread.h"
40 #include "lttng-sessiond.h"
41 #include "health-sessiond.h"
46 #include "notification-thread-commands.h"
49 #include <urcu/list.h>
51 struct lttng_notification_channel
*rotate_notification_channel
= NULL
;
53 struct rotation_thread
{
54 struct lttng_poll_event events
;
57 struct rotation_thread_job
{
58 enum rotation_thread_job_type type
;
60 /* List member in struct rotation_thread_timer_queue. */
61 struct cds_list_head head
;
65 * The timer thread enqueues jobs and wakes up the rotation thread.
66 * When the rotation thread wakes up, it empties the queue.
68 struct rotation_thread_timer_queue
{
69 struct lttng_pipe
*event_pipe
;
70 struct cds_list_head list
;
74 struct rotation_thread_handle
{
76 struct rotation_thread_timer_queue
*rotation_timer_queue
;
77 /* Access to the notification thread cmd_queue */
78 struct notification_thread_handle
*notification_thread_handle
;
79 sem_t
*notification_thread_ready
;
83 const char *get_job_type_str(enum rotation_thread_job_type job_type
)
86 case ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
:
87 return "CHECK_PENDING_ROTATION";
88 case ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION
:
89 return "SCHEDULED_ROTATION";
95 struct rotation_thread_timer_queue
*rotation_thread_timer_queue_create(void)
97 struct rotation_thread_timer_queue
*queue
= NULL
;
99 queue
= zmalloc(sizeof(*queue
));
101 PERROR("Failed to allocate timer rotate queue");
105 queue
->event_pipe
= lttng_pipe_open(FD_CLOEXEC
| O_NONBLOCK
);
106 CDS_INIT_LIST_HEAD(&queue
->list
);
107 pthread_mutex_init(&queue
->lock
, NULL
);
112 void log_job_destruction(const struct rotation_thread_job
*job
)
114 enum lttng_error_level log_level
;
115 const char *job_type_str
= get_job_type_str(job
->type
);
118 case ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION
:
120 * Not a problem, the scheduled rotation is racing with the teardown
121 * of the daemon. In this case, the rotation will not happen, which
122 * is not a problem (or at least, not important enough to delay
123 * the shutdown of the session daemon).
125 log_level
= PRINT_DBG
;
127 case ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
:
128 /* This is not expected to happen; warn the user. */
129 log_level
= PRINT_WARN
;
135 LOG(log_level
, "Rotation thread timer queue still contains job of type %s targeting session %" PRIu64
" on destruction",
136 job_type_str
, job
->session_id
);
139 void rotation_thread_timer_queue_destroy(
140 struct rotation_thread_timer_queue
*queue
)
142 struct rotation_thread_job
*job
, *tmp_job
;
148 lttng_pipe_destroy(queue
->event_pipe
);
150 pthread_mutex_lock(&queue
->lock
);
151 /* Empty wait queue. */
152 cds_list_for_each_entry_safe(job
, tmp_job
, &queue
->list
, head
) {
153 log_job_destruction(job
);
154 cds_list_del(&job
->head
);
157 pthread_mutex_unlock(&queue
->lock
);
158 pthread_mutex_destroy(&queue
->lock
);
163 * Destroy the thread data previously created by the init function.
165 void rotation_thread_handle_destroy(
166 struct rotation_thread_handle
*handle
)
171 struct rotation_thread_handle
*rotation_thread_handle_create(
173 struct rotation_thread_timer_queue
*rotation_timer_queue
,
174 struct notification_thread_handle
*notification_thread_handle
,
175 sem_t
*notification_thread_ready
)
177 struct rotation_thread_handle
*handle
;
179 handle
= zmalloc(sizeof(*handle
));
184 handle
->quit_pipe
= quit_pipe
;
185 handle
->rotation_timer_queue
= rotation_timer_queue
;
186 handle
->notification_thread_handle
= notification_thread_handle
;
187 handle
->notification_thread_ready
= notification_thread_ready
;
194 * Called with the rotation_thread_timer_queue lock held.
195 * Return true if the same timer job already exists in the queue, false if not.
198 bool timer_job_exists(const struct rotation_thread_timer_queue
*queue
,
199 enum rotation_thread_job_type job_type
, uint64_t session_id
)
202 struct rotation_thread_job
*job
;
204 cds_list_for_each_entry(job
, &queue
->list
, head
) {
205 if (job
->session_id
== session_id
&& job
->type
== job_type
) {
214 void rotation_thread_enqueue_job(struct rotation_thread_timer_queue
*queue
,
215 enum rotation_thread_job_type job_type
, uint64_t session_id
)
218 const char * const dummy
= "!";
219 struct rotation_thread_job
*job
= NULL
;
220 const char *job_type_str
= get_job_type_str(job_type
);
222 pthread_mutex_lock(&queue
->lock
);
223 if (timer_job_exists(queue
, session_id
, job_type
)) {
225 * This timer job is already pending, we don't need to add
231 job
= zmalloc(sizeof(struct rotation_thread_job
));
233 PERROR("Failed to allocate rotation thread job of type \"%s\" for session id %" PRIu64
,
234 job_type_str
, session_id
);
237 job
->type
= job_type
;
238 job
->session_id
= session_id
;
239 cds_list_add_tail(&job
->head
, &queue
->list
);
241 ret
= lttng_write(lttng_pipe_get_writefd(queue
->event_pipe
), dummy
,
245 * We do not want to block in the timer handler, the job has
246 * been enqueued in the list, the wakeup pipe is probably full,
247 * the job will be processed when the rotation_thread catches
250 if (errno
== EAGAIN
|| errno
== EWOULDBLOCK
) {
252 * Not an error, but would be surprising and indicate
253 * that the rotation thread can't keep up with the
256 DBG("Wake-up pipe of rotation thread job queue is full");
259 PERROR("Failed to wake-up the rotation thread after pushing a job of type \"%s\" for session id %" PRIu64
,
260 job_type_str
, session_id
);
265 pthread_mutex_unlock(&queue
->lock
);
269 int init_poll_set(struct lttng_poll_event
*poll_set
,
270 struct rotation_thread_handle
*handle
)
275 * Create pollset with size 2:
277 * - rotation thread timer queue pipe,
279 ret
= lttng_poll_create(poll_set
, 2, LTTNG_CLOEXEC
);
284 ret
= lttng_poll_add(poll_set
, handle
->quit_pipe
,
287 ERR("[rotation-thread] Failed to add quit_pipe fd to pollset");
290 ret
= lttng_poll_add(poll_set
,
291 lttng_pipe_get_readfd(handle
->rotation_timer_queue
->event_pipe
),
294 ERR("[rotation-thread] Failed to add rotate_pending fd to pollset");
301 lttng_poll_clean(poll_set
);
306 void fini_thread_state(struct rotation_thread
*state
)
308 lttng_poll_clean(&state
->events
);
309 if (rotate_notification_channel
) {
310 lttng_notification_channel_destroy(rotate_notification_channel
);
315 int init_thread_state(struct rotation_thread_handle
*handle
,
316 struct rotation_thread
*state
)
320 memset(state
, 0, sizeof(*state
));
321 lttng_poll_init(&state
->events
);
323 ret
= init_poll_set(&state
->events
, handle
);
325 ERR("[rotation-thread] Failed to initialize rotation thread poll set");
330 * We wait until the notification thread is ready to create the
331 * notification channel and add it to the poll_set.
333 sem_wait(handle
->notification_thread_ready
);
334 rotate_notification_channel
= lttng_notification_channel_create(
335 lttng_session_daemon_notification_endpoint
);
336 if (!rotate_notification_channel
) {
337 ERR("[rotation-thread] Could not create notification channel");
341 ret
= lttng_poll_add(&state
->events
, rotate_notification_channel
->socket
,
344 ERR("[rotation-thread] Failed to add notification fd to pollset");
353 int check_session_rotation_pending_local_on_consumer(
354 const struct ltt_session
*session
,
355 struct consumer_socket
*socket
, bool *rotation_completed
)
359 pthread_mutex_lock(socket
->lock
);
360 DBG("[rotation-thread] Checking for locally pending rotation on the %s consumer for session %s",
361 lttng_consumer_type_str(socket
->type
),
363 ret
= consumer_check_rotation_pending_local(socket
,
365 session
->current_archive_id
- 1);
366 pthread_mutex_unlock(socket
->lock
);
369 /* Rotation was completed on this consumer. */
370 DBG("[rotation-thread] Local rotation of trace archive %" PRIu64
" of session \"%s\" was completed on the %s consumer",
371 session
->current_archive_id
- 1,
373 lttng_consumer_type_str(socket
->type
));
374 *rotation_completed
= true;
375 } else if (ret
== 1) {
376 /* Rotation pending on this consumer. */
377 DBG("[rotation-thread] Local rotation of trace archive %" PRIu64
" of session \"%s\" is pending on the %s consumer",
378 session
->current_archive_id
- 1,
380 lttng_consumer_type_str(socket
->type
));
381 *rotation_completed
= false;
384 /* Not a fatal error. */
385 ERR("[rotation-thread] Encountered an error when checking if local rotation of trace archive %" PRIu64
" of session \"%s\" is pending on the %s consumer",
386 session
->current_archive_id
- 1,
388 lttng_consumer_type_str(socket
->type
));
389 *rotation_completed
= false;
395 int check_session_rotation_pending_local(struct ltt_session
*session
)
398 struct consumer_socket
*socket
;
399 struct cds_lfht_iter iter
;
400 bool rotation_completed
= true;
403 * Check for a local pending rotation on all consumers (32-bit
404 * user space, 64-bit user space, and kernel).
406 DBG("[rotation-thread] Checking for pending local rotation on session \"%s\", trace archive %" PRIu64
,
407 session
->name
, session
->current_archive_id
- 1);
410 if (!session
->ust_session
) {
413 cds_lfht_for_each_entry(session
->ust_session
->consumer
->socks
->ht
,
414 &iter
, socket
, node
.node
) {
415 ret
= check_session_rotation_pending_local_on_consumer(session
,
416 socket
, &rotation_completed
);
417 if (ret
|| !rotation_completed
) {
423 if (!session
->kernel_session
) {
426 cds_lfht_for_each_entry(session
->kernel_session
->consumer
->socks
->ht
,
427 &iter
, socket
, node
.node
) {
428 ret
= check_session_rotation_pending_local_on_consumer(session
,
429 socket
, &rotation_completed
);
430 if (ret
|| !rotation_completed
) {
438 if (rotation_completed
) {
439 DBG("[rotation-thread] Local rotation of trace archive %" PRIu64
" of session \"%s\" is complete on all consumers",
440 session
->current_archive_id
- 1,
442 session
->rotation_pending_local
= false;
445 session
->rotation_state
= LTTNG_ROTATION_STATE_ERROR
;
451 int check_session_rotation_pending_relay(struct ltt_session
*session
)
454 struct consumer_socket
*socket
;
455 struct cds_lfht_iter iter
;
456 bool rotation_completed
= true;
457 const struct consumer_output
*output
;
460 * Check for a pending rotation on any consumer as we only use
461 * it as a "tunnel" to the relayd.
465 if (session
->ust_session
) {
466 cds_lfht_first(session
->ust_session
->consumer
->socks
->ht
,
468 output
= session
->ust_session
->consumer
;
470 cds_lfht_first(session
->kernel_session
->consumer
->socks
->ht
,
472 output
= session
->kernel_session
->consumer
;
474 assert(cds_lfht_iter_get_node(&iter
));
476 socket
= caa_container_of(cds_lfht_iter_get_node(&iter
),
477 typeof(*socket
), node
.node
);
479 pthread_mutex_lock(socket
->lock
);
480 DBG("[rotation-thread] Checking for pending relay rotation on session \"%s\", trace archive %" PRIu64
" through the %s consumer",
481 session
->name
, session
->current_archive_id
- 1,
482 lttng_consumer_type_str(socket
->type
));
483 ret
= consumer_check_rotation_pending_relay(socket
,
486 session
->current_archive_id
- 1);
487 pthread_mutex_unlock(socket
->lock
);
490 /* Rotation was completed on the relay. */
491 DBG("[rotation-thread] Relay rotation of trace archive %" PRIu64
" of session \"%s\" was completed",
492 session
->current_archive_id
- 1,
494 } else if (ret
== 1) {
495 /* Rotation pending on relay. */
496 DBG("[rotation-thread] Relay rotation of trace archive %" PRIu64
" of session \"%s\" is pending",
497 session
->current_archive_id
- 1,
499 rotation_completed
= false;
501 /* Not a fatal error. */
502 ERR("[rotation-thread] Encountered an error when checking if rotation of trace archive %" PRIu64
" of session \"%s\" is pending on the relay",
503 session
->current_archive_id
- 1,
505 session
->rotation_state
= LTTNG_ROTATION_STATE_ERROR
;
506 rotation_completed
= false;
511 if (rotation_completed
) {
512 DBG("[rotation-thread] Totation of trace archive %" PRIu64
" of session \"%s\" is complete on the relay",
513 session
->current_archive_id
- 1,
515 session
->rotation_pending_relay
= false;
521 * Check if the last rotation was completed, called with session lock held.
524 int check_session_rotation_pending(struct ltt_session
*session
,
525 struct notification_thread_handle
*notification_thread_handle
)
528 struct lttng_trace_archive_location
*location
;
531 DBG("[rotation-thread] Checking for pending rotation on session \"%s\", trace archive %" PRIu64
,
532 session
->name
, session
->current_archive_id
- 1);
534 if (session
->rotation_pending_local
) {
535 /* Updates session->rotation_pending_local as needed. */
536 ret
= check_session_rotation_pending_local(session
);
542 * No need to check for a pending rotation on the relay
543 * since the rotation is not even completed locally yet.
545 if (session
->rotation_pending_local
) {
550 if (session
->rotation_pending_relay
) {
551 /* Updates session->rotation_pending_relay as needed. */
552 ret
= check_session_rotation_pending_relay(session
);
557 if (session
->rotation_pending_relay
) {
562 DBG("[rotation-thread] Rotation of trace archive %" PRIu64
" completed for "
563 "session %s", session
->current_archive_id
- 1,
566 /* Rename the completed trace archive's location. */
568 if (now
== (time_t) -1) {
569 session
->rotation_state
= LTTNG_ROTATION_STATE_ERROR
;
574 ret
= rename_completed_chunk(session
, now
);
576 ERR("Failed to rename completed rotation chunk");
579 session
->last_chunk_start_ts
= session
->current_chunk_start_ts
;
582 * Now we can clear the "ONGOING" state in the session. New
583 * rotations can start now.
585 session
->rotation_state
= LTTNG_ROTATION_STATE_COMPLETED
;
587 /* Ownership of location is transferred. */
588 location
= session_get_trace_archive_location(session
);
589 ret
= notification_thread_command_session_rotation_completed(
590 notification_thread_handle
,
594 session
->current_archive_id
,
596 if (ret
!= LTTNG_OK
) {
597 ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s",
601 if (!session
->active
) {
603 * A stop command was issued during the rotation, it is
604 * up to the rotation completion check to perform the
605 * renaming of the last chunk that was produced.
607 ret
= notification_thread_command_session_rotation_ongoing(
608 notification_thread_handle
,
612 session
->current_archive_id
);
613 if (ret
!= LTTNG_OK
) {
614 ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s",
618 ret
= rename_active_chunk(session
);
620 ERR("[rotation-thread] Failed to rename active rotation chunk");
624 /* Ownership of location is transferred. */
625 location
= session_get_trace_archive_location(session
);
626 ret
= notification_thread_command_session_rotation_completed(
627 notification_thread_handle
,
631 session
->current_archive_id
,
633 if (ret
!= LTTNG_OK
) {
634 ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s",
641 if (session
->rotation_state
== LTTNG_ROTATION_STATE_ONGOING
) {
642 DBG("[rotation-thread] Rotation of trace archive %" PRIu64
" is still pending for session %s",
643 session
->current_archive_id
- 1, session
->name
);
644 ret
= timer_session_rotation_pending_check_start(session
,
645 DEFAULT_ROTATE_PENDING_TIMER
);
647 ERR("Re-enabling rotate pending timer");
656 /* Call with the session lock held. */
658 int launch_session_rotation(struct ltt_session
*session
)
661 struct lttng_rotate_session_return rotation_return
;
663 DBG("[rotation-thread] Launching scheduled time-based rotation on session \"%s\"",
666 ret
= cmd_rotate_session(session
, &rotation_return
);
667 if (ret
== LTTNG_OK
) {
668 DBG("[rotation-thread] Scheduled time-based rotation successfully launched on session \"%s\"",
671 /* Don't consider errors as fatal. */
672 DBG("[rotation-thread] Scheduled time-based rotation aborted for session %s: %s",
673 session
->name
, lttng_strerror(ret
));
679 int run_job(struct rotation_thread_job
*job
, struct ltt_session
*session
,
680 struct notification_thread_handle
*notification_thread_handle
)
685 case ROTATION_THREAD_JOB_TYPE_SCHEDULED_ROTATION
:
686 ret
= launch_session_rotation(session
);
688 case ROTATION_THREAD_JOB_TYPE_CHECK_PENDING_ROTATION
:
689 ret
= check_session_rotation_pending(session
,
690 notification_thread_handle
);
699 int handle_job_queue(struct rotation_thread_handle
*handle
,
700 struct rotation_thread
*state
,
701 struct rotation_thread_timer_queue
*queue
)
704 int fd
= lttng_pipe_get_readfd(queue
->event_pipe
);
705 struct ltt_session
*session
;
708 ret
= lttng_read(fd
, &buf
, 1);
710 ERR("[rotation-thread] Failed to read from wakeup pipe (fd = %i)", fd
);
716 struct rotation_thread_job
*job
;
718 /* Take the queue lock only to pop an element from the list. */
719 pthread_mutex_lock(&queue
->lock
);
720 if (cds_list_empty(&queue
->list
)) {
721 pthread_mutex_unlock(&queue
->lock
);
724 job
= cds_list_first_entry(&queue
->list
,
726 cds_list_del(&job
->head
);
727 pthread_mutex_unlock(&queue
->lock
);
730 session
= session_find_by_id(job
->session_id
);
732 DBG("[rotation-thread] Session %" PRIu64
" not found",
735 * This is a non-fatal error, and we cannot report it to
736 * the user (timer), so just print the error and
737 * continue the processing.
739 * While the timer thread will purge pending signals for
740 * a session on the session's destruction, it is
741 * possible for a job targeting that session to have
742 * already been queued before it was destroyed.
744 session_unlock_list();
749 session_lock(session
);
750 session_unlock_list();
752 ret
= run_job(job
, session
, handle
->notification_thread_handle
);
753 session_unlock(session
);
767 int handle_condition(const struct lttng_condition
*condition
,
768 const struct lttng_evaluation
*evaluation
,
769 struct notification_thread_handle
*notification_thread_handle
)
772 const char *condition_session_name
= NULL
;
773 enum lttng_condition_type condition_type
;
774 enum lttng_condition_status condition_status
;
775 enum lttng_evaluation_status evaluation_status
;
777 struct ltt_session
*session
;
779 condition_type
= lttng_condition_get_type(condition
);
781 if (condition_type
!= LTTNG_CONDITION_TYPE_SESSION_CONSUMED_SIZE
) {
783 ERR("[rotation-thread] Condition type and session usage type are not the same");
787 /* Fetch info to test */
788 condition_status
= lttng_condition_session_consumed_size_get_session_name(
789 condition
, &condition_session_name
);
790 if (condition_status
!= LTTNG_CONDITION_STATUS_OK
) {
791 ERR("[rotation-thread] Session name could not be fetched");
795 evaluation_status
= lttng_evaluation_session_consumed_size_get_consumed_size(evaluation
,
797 if (evaluation_status
!= LTTNG_EVALUATION_STATUS_OK
) {
798 ERR("[rotation-thread] Failed to get evaluation");
804 session
= session_find_by_name(condition_session_name
);
807 session_unlock_list();
808 ERR("[rotation-thread] Session \"%s\" not found",
809 condition_session_name
);
812 session_lock(session
);
813 session_unlock_list();
815 ret
= unsubscribe_session_consumed_size_rotation(session
,
816 notification_thread_handle
);
821 ret
= cmd_rotate_session(session
, NULL
);
822 if (ret
== -LTTNG_ERR_ROTATION_PENDING
) {
823 DBG("Rotate already pending, subscribe to the next threshold value");
824 } else if (ret
!= LTTNG_OK
) {
825 ERR("[rotation-thread] Failed to rotate on size notification with error: %s",
826 lttng_strerror(ret
));
830 ret
= subscribe_session_consumed_size_rotation(session
,
831 consumed
+ session
->rotate_size
,
832 notification_thread_handle
);
834 ERR("[rotation-thread] Failed to subscribe to session consumed size condition");
840 session_unlock(session
);
846 int handle_notification_channel(int fd
,
847 struct rotation_thread_handle
*handle
,
848 struct rotation_thread
*state
)
851 bool notification_pending
;
852 struct lttng_notification
*notification
= NULL
;
853 enum lttng_notification_channel_status status
;
854 const struct lttng_evaluation
*notification_evaluation
;
855 const struct lttng_condition
*notification_condition
;
857 status
= lttng_notification_channel_has_pending_notification(
858 rotate_notification_channel
, ¬ification_pending
);
859 if (status
!= LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
) {
860 ERR("[rotation-thread ]Error occured while checking for pending notification");
865 if (!notification_pending
) {
870 /* Receive the next notification. */
871 status
= lttng_notification_channel_get_next_notification(
872 rotate_notification_channel
,
876 case LTTNG_NOTIFICATION_CHANNEL_STATUS_OK
:
878 case LTTNG_NOTIFICATION_CHANNEL_STATUS_NOTIFICATIONS_DROPPED
:
879 /* Not an error, we will wait for the next one */
882 case LTTNG_NOTIFICATION_CHANNEL_STATUS_CLOSED
:
883 ERR("Notification channel was closed");
887 /* Unhandled conditions / errors. */
888 ERR("Unknown notification channel status");
893 notification_condition
= lttng_notification_get_condition(notification
);
894 notification_evaluation
= lttng_notification_get_evaluation(notification
);
896 ret
= handle_condition(notification_condition
, notification_evaluation
,
897 handle
->notification_thread_handle
);
900 lttng_notification_destroy(notification
);
904 void *thread_rotation(void *data
)
907 struct rotation_thread_handle
*handle
= data
;
908 struct rotation_thread thread
;
910 DBG("[rotation-thread] Started rotation thread");
913 ERR("[rotation-thread] Invalid thread context provided");
917 rcu_register_thread();
920 health_register(health_sessiond
, HEALTH_SESSIOND_TYPE_ROTATION
);
921 health_code_update();
923 ret
= init_thread_state(handle
, &thread
);
928 /* Ready to handle client connections. */
929 sessiond_notify_ready();
935 DBG("[rotation-thread] Entering poll wait");
936 ret
= lttng_poll_wait(&thread
.events
, -1);
937 DBG("[rotation-thread] Poll wait returned (%i)", ret
);
941 * Restart interrupted system call.
943 if (errno
== EINTR
) {
946 ERR("[rotation-thread] Error encountered during lttng_poll_wait (%i)", ret
);
951 for (i
= 0; i
< fd_count
; i
++) {
952 int fd
= LTTNG_POLL_GETFD(&thread
.events
, i
);
953 uint32_t revents
= LTTNG_POLL_GETEV(&thread
.events
, i
);
955 DBG("[rotation-thread] Handling fd (%i) activity (%u)",
958 if (revents
& LPOLLERR
) {
959 ERR("[rotation-thread] Polling returned an error on fd %i", fd
);
963 if (fd
== handle
->quit_pipe
) {
964 DBG("[rotation-thread] Quit pipe activity");
965 /* TODO flush the queue. */
967 } else if (fd
== lttng_pipe_get_readfd(handle
->rotation_timer_queue
->event_pipe
)) {
968 ret
= handle_job_queue(handle
, &thread
,
969 handle
->rotation_timer_queue
);
971 ERR("[rotation-thread] Failed to handle rotation timer pipe event");
974 } else if (fd
== rotate_notification_channel
->socket
) {
975 ret
= handle_notification_channel(fd
, handle
,
978 ERR("[rotation-thread] Error occured while handling activity on notification channel socket");
986 DBG("[rotation-thread] Exit");
987 fini_thread_state(&thread
);
988 health_unregister(health_sessiond
);
989 rcu_thread_offline();
990 rcu_unregister_thread();