sessiond: rename locked_ptr to locked_ref
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 22 May 2024 17:20:46 +0000 (17:20 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 27 Jun 2024 15:09:20 +0000 (11:09 -0400)
The locked_ref semantics garantee that an instance of an is locked and that it
exists (it can't be null). It is currently implemented with a unique_ptr, but
that will most likely change in the future to enforce the non-null requirement.

Change-Id: I6442840f944ded1ddc46cad3d23e8e0fe8fef586
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/rotation-thread.cpp
src/bin/lttng-sessiond/session.cpp
src/bin/lttng-sessiond/session.hpp
src/bin/lttng-sessiond/ust-app.cpp
src/bin/lttng-sessiond/ust-app.hpp
src/bin/lttng-sessiond/ust-registry-session.cpp
src/bin/lttng-sessiond/ust-registry-session.hpp

index a26b38eebca970230f3a02d8bee8c9fdcba92bc0..418a2d62bcf032ec54db286ddf92815180968633 100644 (file)
@@ -543,9 +543,9 @@ void ls::rotation_thread::_handle_job_queue()
                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. */
+               /* locked_ref will unlock the session and release the ref held by the job. */
                session_lock(job->session);
-               auto session = ltt_session::locked_ptr(job->session);
+               auto session = ltt_session::locked_ref(job->session);
 
                if (run_job(*job, *session, _notification_thread_handle)) {
                        return;
@@ -588,7 +588,7 @@ void ls::rotation_thread::_handle_notification(const lttng_notification& notific
        session_lock_list();
        const auto unlock_list = lttng::make_scope_exit([]() noexcept { session_unlock_list(); });
 
-       ltt_session::locked_ptr session{ [&condition_session_name]() {
+       ltt_session::locked_ref session{ [&condition_session_name]() {
                auto raw_session_ptr = session_find_by_name(condition_session_name);
 
                if (raw_session_ptr) {
index 0ad891e3252e4e294aaf23026abac9a394080117..ccd4221a242d858be5201237e84fb12f503a64a2 100644 (file)
@@ -1437,7 +1437,7 @@ void ls::details::locked_session_release(ltt_session *session)
        session_put(session);
 }
 
-ltt_session::locked_ptr ls::find_locked_session_by_id(ltt_session::id_t id)
+ltt_session::locked_ref ls::find_locked_session_by_id(ltt_session::id_t id)
 {
        lttng::urcu::read_lock_guard rcu_lock;
        auto session = session_find_by_id(id);
@@ -1451,7 +1451,7 @@ ltt_session::locked_ptr ls::find_locked_session_by_id(ltt_session::id_t id)
         * session.
         */
        session_lock(session);
-       return ltt_session::locked_ptr(session);
+       return ltt_session::locked_ref(session);
 }
 
 ltt_session::sptr ls::find_session_by_id(ltt_session::id_t id)
index 587c9e08381e5049dc2b0131d947b42410a6b947..f5f8ae7bcca08dd06002097c2f988292d8bbcfe7 100644 (file)
@@ -77,7 +77,7 @@ struct ltt_session_list {
  */
 struct ltt_session {
        using id_t = uint64_t;
-       using locked_ptr =
+       using locked_ref =
                std::unique_ptr<ltt_session,
                                lttng::memory::create_deleter_class<
                                        ltt_session,
@@ -317,7 +317,7 @@ namespace sessiond {
  * for longer than strictly necessary. If your intention is to acquire
  * a reference to an ltt_session, see `find_session_by_id()`.
  */
-ltt_session::locked_ptr find_locked_session_by_id(ltt_session::id_t id);
+ltt_session::locked_ref find_locked_session_by_id(ltt_session::id_t id);
 
 ltt_session::sptr find_session_by_id(ltt_session::id_t id);
 
index d993b7b4439059f2448940f7b3130a2e638e3954..2788ddbe07d489d7436af922b380743539c9f5a3 100644 (file)
@@ -121,14 +121,14 @@ error:
        return registry;
 }
 
-lsu::registry_session::locked_ptr get_locked_session_registry(const struct ust_app_session *ua_sess)
+lsu::registry_session::locked_ref get_locked_session_registry(const struct ust_app_session *ua_sess)
 {
        auto session = get_session_registry(ua_sess);
        if (session) {
                pthread_mutex_lock(&session->_lock);
        }
 
-       return lsu::registry_session::locked_ptr{ session };
+       return lsu::registry_session::locked_ref{ session };
 }
 } /* namespace */
 
@@ -561,7 +561,7 @@ end:
 static void delete_ust_app_channel(int sock,
                                   struct ust_app_channel *ua_chan,
                                   struct ust_app *app,
-                                  const lsu::registry_session::locked_ptr& locked_registry)
+                                  const lsu::registry_session::locked_ref& locked_registry)
 {
        int ret;
        struct lttng_ht_iter iter;
@@ -687,7 +687,7 @@ int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data
  * but it can be caused by recoverable errors (e.g. the application has
  * terminated concurrently).
  */
-ssize_t ust_app_push_metadata(const lsu::registry_session::locked_ptr& locked_registry,
+ssize_t ust_app_push_metadata(const lsu::registry_session::locked_ref& locked_registry,
                              struct consumer_socket *socket,
                              int send_zero_data)
 {
@@ -826,7 +826,7 @@ error_push:
  * but it can be caused by recoverable errors (e.g. the application has
  * terminated concurrently).
  */
-static int push_metadata(const lsu::registry_session::locked_ptr& locked_registry,
+static int push_metadata(const lsu::registry_session::locked_ref& locked_registry,
                         struct consumer_output *consumer)
 {
        int ret_val;
index 64df1c2955abf4ca2b02ffd8136879c8bcd68923..7a3f875915659833d22d6b2eb2795ed4292ad93a 100644 (file)
@@ -403,7 +403,7 @@ int ust_app_recv_notify(int sock);
 void ust_app_add(struct ust_app *app);
 struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
 void ust_app_notify_sock_unregister(int sock);
-ssize_t ust_app_push_metadata(const lttng::sessiond::ust::registry_session::locked_ptr& registry,
+ssize_t ust_app_push_metadata(const lttng::sessiond::ust::registry_session::locked_ref& registry,
                              struct consumer_socket *socket,
                              int send_zero_data);
 enum lttng_error_code ust_app_snapshot_record(const struct ltt_ust_session *usess,
index d0891fe9a87325a3d245e52cbe001c5a2c401c41..50118472428c7bb4b8dc709fc0584aaf73a16ba2 100644 (file)
@@ -432,10 +432,10 @@ lsu::registry_session::~registry_session()
        }
 }
 
-lsu::registry_session::locked_ptr lsu::registry_session::lock() noexcept
+lsu::registry_session::locked_ref lsu::registry_session::lock() noexcept
 {
        pthread_mutex_lock(&_lock);
-       return locked_ptr(this);
+       return locked_ref(this);
 }
 
 /*
index 7f407e13ae6edcab0bbb0fba594589fa5edcdb03..404eabbe08ee777a26fbd8e6a4425a296bfa0921 100644 (file)
@@ -37,14 +37,14 @@ void locked_registry_session_release(registry_session *session);
 
 class registry_session : public lttng::sessiond::trace::trace_class {
 public:
-       using locked_ptr =
+       using locked_ref =
                std::unique_ptr<registry_session,
                                lttng::memory::create_deleter_class<
                                        registry_session,
                                        details::locked_registry_session_release>::deleter>;
 
        virtual lttng_buffer_type buffering_scheme() const noexcept = 0;
-       locked_ptr lock() noexcept;
+       locked_ref lock() noexcept;
 
        void add_channel(uint64_t channel_key);
 
This page took 0.03335 seconds and 4 git commands to generate.