From: Jérémie Galarneau Date: Wed, 22 May 2024 17:20:46 +0000 (+0000) Subject: sessiond: rename locked_ptr to locked_ref X-Git-Url: http://git.lttng.org./?a=commitdiff_plain;h=77682be970310bf033d7d2a56fb1a090b5ffddcf;p=lttng-tools.git sessiond: rename locked_ptr to locked_ref 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 --- diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index a26b38eeb..418a2d62b 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -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) { diff --git a/src/bin/lttng-sessiond/session.cpp b/src/bin/lttng-sessiond/session.cpp index 0ad891e32..ccd4221a2 100644 --- a/src/bin/lttng-sessiond/session.cpp +++ b/src/bin/lttng-sessiond/session.cpp @@ -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) diff --git a/src/bin/lttng-sessiond/session.hpp b/src/bin/lttng-sessiond/session.hpp index 587c9e083..f5f8ae7bc 100644 --- a/src/bin/lttng-sessiond/session.hpp +++ b/src/bin/lttng-sessiond/session.hpp @@ -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_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; diff --git a/src/bin/lttng-sessiond/ust-app.hpp b/src/bin/lttng-sessiond/ust-app.hpp index 64df1c295..7a3f87591 100644 --- a/src/bin/lttng-sessiond/ust-app.hpp +++ b/src/bin/lttng-sessiond/ust-app.hpp @@ -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, diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index d0891fe9a..501184724 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -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); } /* diff --git a/src/bin/lttng-sessiond/ust-registry-session.hpp b/src/bin/lttng-sessiond/ust-registry-session.hpp index 7f407e13a..404eabbe0 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.hpp +++ b/src/bin/lttng-sessiond/ust-registry-session.hpp @@ -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::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);