Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / src / bin / lttng-sessiond / rotation-thread.cpp
index 6f58a178d3abfe9aa34df0b669765341a66d9d10..a26b38eebca970230f3a02d8bee8c9fdcba92bc0 100644 (file)
@@ -44,6 +44,7 @@
 #include <lttng/rotate-internal.hpp>
 #include <lttng/trigger/trigger.h>
 
+#include <fcntl.h>
 #include <inttypes.h>
 #include <memory>
 #include <signal.h>
@@ -67,9 +68,10 @@ struct ls::rotation_thread_timer_queue {
 
 namespace {
 struct rotation_thread_job {
-       using uptr = std::unique_ptr<
-               rotation_thread_job,
-               lttng::details::create_unique_class<rotation_thread_job, lttng::free>>;
+       using uptr =
+               std::unique_ptr<rotation_thread_job,
+                               lttng::memory::create_deleter_class<rotation_thread_job,
+                                                                   lttng::memory::free>::deleter>;
 
        enum ls::rotation_thread_job_type type;
        struct ltt_session *session;
@@ -393,11 +395,10 @@ void ls::rotation_thread_timer_queue_destroy(struct rotation_thread_timer_queue
        free(queue);
 }
 
-ls::rotation_thread::rotation_thread(
-       rotation_thread_timer_queue& rotation_timer_queue,
-       notification_thread_handle& notification_thread_handle) :
-       _rotation_timer_queue{ rotation_timer_queue },
-       _notification_thread_handle{ notification_thread_handle }
+ls::rotation_thread::rotation_thread(rotation_thread_timer_queue& rotation_timer_queue,
+                                    notification_thread_handle& notification_thread_handle) :
+       _rotation_timer_queue(rotation_timer_queue),
+       _notification_thread_handle(notification_thread_handle)
 {
        _quit_pipe.reset([]() {
                auto raw_pipe = lttng_pipe_open(FD_CLOEXEC);
@@ -460,8 +461,8 @@ ls::rotation_thread::~rotation_thread()
 }
 
 void ls::rotation_thread_enqueue_job(ls::rotation_thread_timer_queue *queue,
-                                ls::rotation_thread_job_type job_type,
-                                ltt_session *session)
+                                    ls::rotation_thread_job_type job_type,
+                                    ltt_session *session)
 {
        const char dummy = '!';
        struct rotation_thread_job *job = nullptr;
@@ -539,7 +540,8 @@ void ls::rotation_thread::_handle_job_queue()
                }
 
                session_lock_list();
-               const auto unlock_list = lttng::make_scope_exit([]() noexcept { session_unlock_list(); });
+               const auto unlock_list =
+                       lttng::make_scope_exit([]() noexcept { session_unlock_list(); });
 
                /* locked_ptr will unlock the session and release the ref held by the job. */
                session_lock(job->session);
@@ -551,7 +553,7 @@ void ls::rotation_thread::_handle_job_queue()
        }
 }
 
-void ls::rotation_thread::_handle_notification(const lttng_notification &notification)
+void ls::rotation_thread::_handle_notification(const lttng_notificationnotification)
 {
        int ret = 0;
        const char *condition_session_name = nullptr;
@@ -751,8 +753,8 @@ void ls::rotation_thread::_run()
                        DBG_FMT("Handling descriptor activity: fd={}, events={:b}", fd, revents);
 
                        if (revents & LPOLLERR) {
-                               LTTNG_THROW_ERROR(
-                                       fmt::format("Polling returned an error on fd: fd={}", fd));
+                               LTTNG_THROW_ERROR(lttng::format(
+                                       "Polling returned an error on fd: fd={}", fd));
                        }
 
                        if (fd == _notification_channel->socket ||
@@ -770,7 +772,8 @@ void ls::rotation_thread::_run()
                                }
 
                                if (fd == _notification_channel_subscribtion_change_eventfd.fd()) {
-                                       _notification_channel_subscribtion_change_eventfd.decrement();
+                                       _notification_channel_subscribtion_change_eventfd
+                                               .decrement();
                                }
                        } else {
                                /* Job queue or quit pipe activity. */
@@ -787,7 +790,7 @@ void ls::rotation_thread::_run()
 
                                        if (lttng_read(fd, &buf, 1) != 1) {
                                                LTTNG_THROW_POSIX(
-                                                       fmt::format(
+                                                       lttng::format(
                                                                "Failed to read from wakeup pipe: fd={}",
                                                                fd),
                                                        errno);
@@ -829,7 +832,7 @@ void ls::rotation_thread::launch_thread()
 }
 
 void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session& session,
-                                                                         std::uint64_t size)
+                                                                  std::uint64_t size)
 {
        const struct lttng_credentials session_creds = {
                .uid = LTTNG_OPTIONAL_INIT_VALUE(session.uid),
@@ -847,14 +850,14 @@ void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session&
        auto condition_status =
                lttng_condition_session_consumed_size_set_threshold(rotate_condition.get(), size);
        if (condition_status != LTTNG_CONDITION_STATUS_OK) {
-               LTTNG_THROW_ERROR(fmt::format(
+               LTTNG_THROW_ERROR(lttng::format(
                        "Could not set session consumed size condition threshold: size={}", size));
        }
 
-       condition_status = lttng_condition_session_consumed_size_set_session_name(rotate_condition.get(),
-                                                                                 session.name);
+       condition_status = lttng_condition_session_consumed_size_set_session_name(
+               rotate_condition.get(), session.name);
        if (condition_status != LTTNG_CONDITION_STATUS_OK) {
-               LTTNG_THROW_ERROR(fmt::format(
+               LTTNG_THROW_ERROR(lttng::format(
                        "Could not set session consumed size condition session name: name=`{}`",
                        session.name));
        }
@@ -869,8 +872,7 @@ void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session&
        /* trigger acquires its own reference to condition and action on success. */
        auto trigger = lttng::make_unique_wrapper<lttng_trigger, lttng_trigger_put>(
                lttng_trigger_create(rotate_condition.get(), notify_action.get()));
-       if (!trigger)
-       {
+       if (!trigger) {
                LTTNG_THROW_POSIX("Could not create size-based rotation trigger", errno);
        }
 
@@ -878,8 +880,8 @@ void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session&
        lttng_trigger_set_hidden(trigger.get());
        lttng_trigger_set_credentials(trigger.get(), &session_creds);
 
-       auto nc_status =
-               lttng_notification_channel_subscribe(_notification_channel.get(), rotate_condition.get());
+       auto nc_status = lttng_notification_channel_subscribe(_notification_channel.get(),
+                                                             rotate_condition.get());
        if (nc_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
                LTTNG_THROW_ERROR("Could not subscribe to session consumed size notification");
        }
@@ -894,7 +896,7 @@ void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session&
                &_notification_thread_handle, trigger.get(), true);
        if (register_ret != LTTNG_OK) {
                LTTNG_THROW_CTL(
-                       fmt::format(
+                       lttng::format(
                                "Failed to register trigger for automatic size-based rotation: session_name{}, size={}",
                                session.name,
                                size),
@@ -918,7 +920,7 @@ void ls::rotation_thread::unsubscribe_session_consumed_size_rotation(ltt_session
                _notification_channel.get(),
                lttng_trigger_get_const_condition(session.rotate_trigger));
        if (unsubscribe_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
-               LTTNG_THROW_ERROR(fmt::format(
+               LTTNG_THROW_ERROR(lttng::format(
                        "Failed to unsubscribe from consumed size condition used to control automatic size-based rotations: session_name=`{}` return_code={}",
                        session.name,
                        static_cast<int>(unsubscribe_status)));
@@ -934,7 +936,7 @@ void ls::rotation_thread::unsubscribe_session_consumed_size_rotation(ltt_session
                &_notification_thread_handle, session.rotate_trigger);
        if (unregister_status != LTTNG_OK) {
                LTTNG_THROW_CTL(
-                       fmt::format(
+                       lttng::format(
                                "Failed to unregister trigger for automatic size-based rotation: session_name{}",
                                session.name),
                        unregister_status);
This page took 0.026107 seconds and 4 git commands to generate.