2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
10 #include "ust-registry.hpp"
11 #include "lttng-sessiond.hpp"
12 #include "notification-thread-commands.hpp"
13 #include "ust-app.hpp"
14 #include "ust-registry-session-pid.hpp"
15 #include "ust-registry-session-uid.hpp"
18 #include <common/common.hpp>
19 #include <common/exception.hpp>
20 #include <common/format.hpp>
21 #include <common/hashtable/utils.hpp>
22 #include <common/make-unique-wrapper.hpp>
23 #include <lttng/lttng.h>
27 namespace ls
= lttng::sessiond
;
28 namespace lst
= lttng::sessiond::trace
;
29 namespace lsu
= lttng::sessiond::ust
;
32 * Destroy event function call of the call RCU.
34 static void ust_registry_event_destroy_rcu(struct rcu_head
*head
)
37 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
38 lttng::sessiond::ust::registry_event
*event
=
39 lttng::utils::container_of(head
, <tng::sessiond::ust::registry_event::_head
);
42 lttng::sessiond::ust::registry_event_destroy(event
);
46 * For a given event in a registry, delete the entry and destroy the event.
47 * This MUST be called within a RCU read side lock section.
49 void ust_registry_channel_destroy_event(lsu::registry_channel
*chan
,
50 lttng::sessiond::ust::registry_event
*event
)
53 struct lttng_ht_iter iter
;
57 ASSERT_RCU_READ_LOCKED();
59 /* Delete the node first. */
60 iter
.iter
.node
= &event
->_node
;
61 ret
= lttng_ht_del(chan
->_events
, &iter
);
64 call_rcu(&event
->_head
, ust_registry_event_destroy_rcu
);
69 lsu::registry_session
*ust_registry_session_per_uid_create(const lttng::sessiond::trace::abi
& abi
,
72 const char *root_shm_path
,
80 return new lsu::registry_session_per_uid(abi
, major
, minor
, root_shm_path
, shm_path
,
81 euid
, egid
, tracing_id
, tracing_uid
);
82 } catch (const std::exception
& ex
) {
83 ERR("Failed to create per-uid registry session: %s", ex
.what());
88 lsu::registry_session
*ust_registry_session_per_pid_create(struct ust_app
*app
,
89 const lttng::sessiond::trace::abi
& abi
,
92 const char *root_shm_path
,
99 return new lsu::registry_session_per_pid(*app
, abi
, major
, minor
, root_shm_path
,
100 shm_path
, euid
, egid
, tracing_id
);
101 } catch (const std::exception
& ex
) {
102 ERR("Failed to create per-pid registry session: %s", ex
.what());
108 * Destroy session registry. This does NOT free the given pointer since it
109 * might get passed as a reference. The registry lock should NOT be acquired.
111 void ust_registry_session_destroy(lsu::registry_session
*reg
)
116 lsu::registry_enum::registry_enum(
117 std::string in_name
, enum lst::integer_type::signedness in_signedness
) :
118 name
{std::move(in_name
)}, signedness
{in_signedness
}
120 cds_lfht_node_init(&this->node
.node
);
124 bool lsu::operator==(const lsu::registry_enum
& lhs
, const lsu::registry_enum
& rhs
) noexcept
126 if (lhs
.signedness
!= rhs
.signedness
) {
130 return lhs
._is_equal(rhs
);