2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #include "ctf2-trace-class-visitor.hpp"
10 #include "lttng-sessiond.hpp"
11 #include "notification-thread-commands.hpp"
12 #include "session.hpp"
13 #include "trace-class.hpp"
14 #include "tsdl-trace-class-visitor.hpp"
15 #include "ust-app.hpp"
16 #include "ust-field-quirks.hpp"
17 #include "ust-registry-session.hpp"
18 #include "ust-registry.hpp"
20 #include <common/compat/directory-handle.hpp>
21 #include <common/error.hpp>
22 #include <common/exception.hpp>
23 #include <common/format.hpp>
24 #include <common/hashtable/utils.hpp>
25 #include <common/macros.hpp>
26 #include <common/make-unique.hpp>
27 #include <common/pthread-lock.hpp>
28 #include <common/runas.hpp>
29 #include <common/time.hpp>
30 #include <common/urcu.hpp>
34 #include <initializer_list>
39 namespace ls
= lttng::sessiond
;
40 namespace lst
= lttng::sessiond::trace
;
41 namespace lsu
= lttng::sessiond::ust
;
44 lttng_uuid
generate_uuid_or_throw()
48 if (lttng_uuid_generate(new_uuid
)) {
49 LTTNG_THROW_POSIX("Failed to generate UST uuid", errno
);
55 int get_count_order(unsigned int count
)
59 order
= lttng_fls(count
) - 1;
60 if (count
& (count
- 1)) {
64 LTTNG_ASSERT(order
>= 0);
68 void clear_metadata_file(int fd
)
70 const auto lseek_ret
= lseek(fd
, 0, SEEK_SET
);
73 "Failed to seek to the beginning of the metadata file while clearing it",
77 const auto ret
= ftruncate(fd
, 0);
79 LTTNG_THROW_POSIX("Failed to truncate the metadata file while clearing it", errno
);
84 * Validate that the id has reached the maximum allowed or not.
86 bool is_max_channel_id(uint32_t id
)
88 return id
== UINT32_MAX
;
91 void destroy_channel_rcu(struct rcu_head
*head
)
94 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
95 lsu::registry_channel
*chan
=
96 lttng::utils::container_of(head
, &lsu::registry_channel::_rcu_head
);
103 * Destroy every element of the registry and free the memory. This does NOT
104 * free the registry pointer since it might not have been allocated before so
105 * it's the caller responsability.
107 * Called from ~registry_session(), must not throw.
109 void destroy_channel(lsu::registry_channel
*chan
, bool notify
) noexcept
111 struct lttng_ht_iter iter
;
112 lttng::sessiond::ust::registry_event
*event
;
113 enum lttng_error_code cmd_ret
;
118 cmd_ret
= notification_thread_command_remove_channel(
119 the_notification_thread_handle
, chan
->_consumer_key
, LTTNG_DOMAIN_UST
);
120 if (cmd_ret
!= LTTNG_OK
) {
121 ERR("Failed to remove channel from notification thread");
126 lttng::urcu::read_lock_guard read_lock_guard
;
128 /* Destroy all event associated with this registry. */
130 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
131 cds_lfht_for_each_entry (chan
->_events
->ht
, &iter
.iter
, event
, _node
) {
132 /* Delete the node from the ht and free it. */
133 ust_registry_channel_destroy_event(chan
, event
);
138 call_rcu(&chan
->_rcu_head
, destroy_channel_rcu
);
141 void destroy_enum(lsu::registry_enum
*reg_enum
)
150 void destroy_enum_rcu(struct rcu_head
*head
)
153 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
154 lsu::registry_enum
*reg_enum
=
155 lttng::utils::container_of(head
, &lsu::registry_enum::rcu_head
);
158 destroy_enum(reg_enum
);
162 * Hash table match function for enumerations in the session. Match is
163 * performed on enumeration name, and confirmed by comparing the enum
166 int ht_match_enum(struct cds_lfht_node
*node
, const void *_key
)
168 lsu::registry_enum
*_enum
;
169 const lsu::registry_enum
*key
;
175 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
176 _enum
= caa_container_of(node
, lsu::registry_enum
, node
.node
);
180 key
= (lsu::registry_enum
*) _key
;
182 return *_enum
== *key
;
186 * Hash table match function for enumerations in the session. Match is
187 * performed by enumeration ID.
189 int ht_match_enum_id(struct cds_lfht_node
*node
, const void *_key
)
191 lsu::registry_enum
*_enum
;
192 const lsu::registry_enum
*key
= (lsu::registry_enum
*) _key
;
198 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
199 _enum
= caa_container_of(node
, lsu::registry_enum
, node
.node
);
204 if (_enum
->id
!= key
->id
) {
216 * Hash table hash function for enumerations in the session. The
217 * enumeration name is used for hashing.
219 unsigned long ht_hash_enum(void *_key
, unsigned long seed
)
221 lsu::registry_enum
*key
= (lsu::registry_enum
*) _key
;
224 return hash_key_str(key
->name
.c_str(), seed
);
228 void lsu::details::locked_registry_session_release(lsu::registry_session
*session
)
230 pthread_mutex_unlock(&session
->_lock
);
233 lsu::registry_session::registry_session(const struct lst::abi
& in_abi
,
236 const char *root_shm_path
,
237 const char *shm_path
,
240 uint64_t tracing_id
) :
241 lst::trace_class(in_abi
, generate_uuid_or_throw()),
242 _root_shm_path
{ root_shm_path
? root_shm_path
: "" },
243 _shm_path
{ shm_path
? shm_path
: "" },
244 _metadata_path
{ _shm_path
.size() > 0 ? lttng::format("{}/metadata", _shm_path
) :
248 _app_tracer_version
{ .major
= major
, .minor
= minor
},
249 _tracing_id
{ tracing_id
},
250 _clock
{ lttng::make_unique
<lsu::clock_class
>() },
251 _metadata_generating_visitor
{ lttng::make_unique
<ls::tsdl::trace_class_visitor
>(
253 [this](const std::string
& fragment
) { _append_metadata_fragment(fragment
); }) },
254 _packet_header
{ _create_packet_header() }
256 pthread_mutex_init(&_lock
, nullptr);
257 if (_shm_path
.size() > 0) {
258 if (run_as_mkdir_recursive(_shm_path
.c_str(), S_IRWXU
| S_IRWXG
, euid
, egid
)) {
259 LTTNG_THROW_POSIX("run_as_mkdir_recursive", errno
);
263 if (_metadata_path
.size() > 0) {
264 /* Create metadata file. */
265 const int ret
= run_as_open(_metadata_path
.c_str(),
266 O_WRONLY
| O_CREAT
| O_EXCL
,
273 "Failed to open metadata file during registry session creation: path = {}",
281 _enums
.reset(lttng_ht_new(0, LTTNG_HT_TYPE_STRING
));
283 LTTNG_THROW_POSIX("Failed to create enums hash table", ENOMEM
);
286 /* hash/match functions are specified at call site. */
287 _enums
->match_fct
= nullptr;
288 _enums
->hash_fct
= nullptr;
290 _channels
.reset(lttng_ht_new(0, LTTNG_HT_TYPE_U64
));
292 LTTNG_THROW_POSIX("Failed to create channels hash table", ENOMEM
);
296 lst::type::cuptr
lsu::registry_session::_create_packet_header() const
298 lst::structure_type::fields packet_header_fields
;
301 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
303 lttng::make_unique
<lst::integer_type
>(
304 abi
.uint32_t_alignment
,
307 lst::integer_type::signedness::UNSIGNED
,
308 lst::integer_type::base::HEXADECIMAL
,
309 std::initializer_list
<lst::integer_type::role
>(
310 { lst::integer_type::role::PACKET_MAGIC_NUMBER
}))));
313 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
315 lttng::make_unique
<lst::static_length_blob_type
>(
318 std::initializer_list
<lst::static_length_blob_type::role
>(
319 { lst::static_length_blob_type::role::METADATA_STREAM_UUID
}))));
321 /* uint32_t stream_id */
322 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
324 lttng::make_unique
<lst::integer_type
>(
325 abi
.uint32_t_alignment
,
328 lst::integer_type::signedness::UNSIGNED
,
329 lst::integer_type::base::DECIMAL
,
330 std::initializer_list
<lst::integer_type::role
>(
331 { lst::integer_type::role::DATA_STREAM_CLASS_ID
}))));
333 /* uint64_t stream_instance_id */
334 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
335 "stream_instance_id",
336 lttng::make_unique
<lst::integer_type
>(
337 abi
.uint64_t_alignment
,
340 lst::integer_type::signedness::UNSIGNED
,
341 lst::integer_type::base::DECIMAL
,
342 std::initializer_list
<lst::integer_type::role
>(
343 { lst::integer_type::role::DATA_STREAM_ID
}))));
345 return lttng::make_unique
<lst::structure_type
>(0, std::move(packet_header_fields
));
348 const lst::type
*lsu::registry_session::packet_header() const noexcept
350 return _packet_header
.get();
354 * For a given enumeration in a registry, delete the entry and destroy
357 * Note that this is used by ~registry_session() and must not throw.
359 void lsu::registry_session::_destroy_enum(lsu::registry_enum
*reg_enum
) noexcept
362 lttng::urcu::read_lock_guard read_lock_guard
;
364 LTTNG_ASSERT(reg_enum
);
365 ASSERT_RCU_READ_LOCKED();
367 /* Delete the node first. */
368 struct lttng_ht_iter iter
;
369 iter
.iter
.node
= ®_enum
->node
.node
;
370 ret
= lttng_ht_del(_enums
.get(), &iter
);
372 call_rcu(®_enum
->rcu_head
, destroy_enum_rcu
);
375 lsu::registry_session::~registry_session()
378 struct lttng_ht_iter iter
;
379 lsu::registry_channel
*chan
;
380 lsu::registry_enum
*reg_enum
;
382 /* On error, EBUSY can be returned if lock. Code flow error. */
383 ret
= pthread_mutex_destroy(&_lock
);
387 lttng::urcu::read_lock_guard read_lock_guard
;
389 /* Destroy all event associated with this registry. */
391 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
392 cds_lfht_for_each_entry (_channels
->ht
, &iter
.iter
, chan
, _node
.node
) {
393 /* Delete the node from the ht and free it. */
394 ret
= lttng_ht_del(_channels
.get(), &iter
);
396 destroy_channel(chan
, true);
402 if (_metadata_fd
>= 0) {
403 ret
= close(_metadata_fd
);
408 ret
= run_as_unlink(_metadata_path
.c_str(), _uid
, _gid
);
414 if (_root_shm_path
[0]) {
415 /* Try to delete the directory hierarchy. */
416 (void) run_as_rmdir_recursive(_root_shm_path
.c_str(),
419 LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG
);
422 /* Destroy the enum hash table */
424 lttng::urcu::read_lock_guard read_lock_guard
;
426 /* Destroy all enum entries associated with this registry. */
428 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
429 cds_lfht_for_each_entry (_enums
->ht
, &iter
.iter
, reg_enum
, node
.node
) {
430 _destroy_enum(reg_enum
);
436 lsu::registry_session::locked_ref
lsu::registry_session::lock() noexcept
438 pthread_mutex_lock(&_lock
);
439 return locked_ref(this);
443 * Initialize registry with default values.
445 void lsu::registry_session::add_channel(uint64_t key
)
447 lttng::pthread::lock_guard
session_lock_guard(_lock
);
450 * Assign a channel ID right now since the event notification comes
451 * *before* the channel notify so the ID needs to be set at this point so
452 * the metadata can be dumped for that event.
454 if (is_max_channel_id(_used_channel_id
)) {
455 LTTNG_THROW_ERROR(lttng::format(
456 "Failed to allocate unique id for channel under session while adding channel"));
459 auto chan
= new lsu::registry_channel(
460 _get_next_channel_id(),
463 /* Registered channel listener. */
464 [this](const lsu::registry_channel
& registered_channel
) {
466 * Channel registration completed, serialize it's layout's
469 registered_channel
.accept(*_metadata_generating_visitor
);
471 /* Added event listener. */
472 [this](const lsu::registry_channel
& channel
,
473 const lsu::registry_event
& added_event
) {
475 * The channel and its event classes will be dumped at once when
476 * it is registered. This check prevents event classes from being
477 * declared before their stream class.
479 if (channel
.is_registered()) {
480 added_event
.accept(*_metadata_generating_visitor
);
484 lttng::urcu::read_lock_guard rcu_read_lock_guard
;
485 lttng_ht_node_init_u64(&chan
->_node
, key
);
486 lttng_ht_add_unique_u64(_channels
.get(), &chan
->_node
);
489 lttng::sessiond::ust::registry_channel
& lsu::registry_session::channel(uint64_t channel_key
) const
491 lttng::urcu::read_lock_guard read_lock_guard
;
492 struct lttng_ht_node_u64
*node
;
493 struct lttng_ht_iter iter
;
495 ASSERT_LOCKED(_lock
);
497 lttng_ht_lookup(_channels
.get(), &channel_key
, &iter
);
498 node
= lttng_ht_iter_get_node
<lttng_ht_node_u64
>(&iter
);
500 LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
501 "Invalid channel key provided: channel key = {}", channel_key
));
505 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
506 auto chan
= lttng::utils::container_of(node
, &lsu::registry_channel::_node
);
511 void lsu::registry_session::remove_channel(uint64_t channel_key
, bool notify
)
513 struct lttng_ht_iter iter
;
515 lttng::urcu::read_lock_guard read_lock_guard
;
517 ASSERT_LOCKED(_lock
);
518 auto& channel_to_remove
= channel(channel_key
);
520 iter
.iter
.node
= &channel_to_remove
._node
.node
;
521 ret
= lttng_ht_del(_channels
.get(), &iter
);
523 destroy_channel(&channel_to_remove
, notify
);
526 void lsu::registry_session::accept(
527 lttng::sessiond::trace::trace_class_environment_visitor
& visitor
) const
529 ASSERT_LOCKED(_lock
);
531 visitor
.visit(lst::environment_field
<const char *>("domain", "ust"));
532 visitor
.visit(lst::environment_field
<const char *>("tracer_name", "lttng-ust"));
533 visitor
.visit(lst::environment_field
<int64_t>("tracer_major", _app_tracer_version
.major
));
534 visitor
.visit(lst::environment_field
<int64_t>("tracer_minor", _app_tracer_version
.minor
));
535 visitor
.visit(lst::environment_field
<const char *>(
536 "tracer_buffering_scheme",
537 buffering_scheme() == LTTNG_BUFFER_PER_PID
? "pid" : "uid"));
538 visitor
.visit(lst::environment_field
<int64_t>("architecture_bit_width", abi
.bits_per_long
));
541 /* The caller already holds the session and session list locks. */
542 ASSERT_SESSION_LIST_LOCKED();
543 const auto session
= ltt_session::find_session(_tracing_id
);
544 ASSERT_LOCKED(session
->_lock
);
546 visitor
.visit(lst::environment_field
<const char *>(
548 session
->has_auto_generated_name
? DEFAULT_SESSION_NAME
: session
->name
));
549 visitor
.visit(lst::environment_field
<std::string
>(
550 "trace_creation_datetime",
551 lttng::utils::time_to_iso8601_str(session
->creation_time
)));
552 visitor
.visit(lst::environment_field
<const char *>("hostname", session
->hostname
));
556 void lsu::registry_session::_accept_on_clock_classes(lst::trace_class_visitor
& visitor
) const
558 ASSERT_LOCKED(_lock
);
559 _clock
->accept(visitor
);
562 void lsu::registry_session::_accept_on_stream_classes(lst::trace_class_visitor
& visitor
) const
564 ASSERT_LOCKED(_lock
);
566 std::vector
<const lttng::sessiond::ust::registry_channel
*> sorted_stream_classes
;
569 lttng::urcu::read_lock_guard rcu_lock_guard
;
570 const lsu::registry_channel
*channel
;
571 lttng_ht_iter channel_it
;
574 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
575 cds_lfht_for_each_entry (_channels
->ht
, &channel_it
.iter
, channel
, _node
.node
) {
576 sorted_stream_classes
.emplace_back(channel
);
581 std::sort(sorted_stream_classes
.begin(),
582 sorted_stream_classes
.end(),
583 [](const lttng::sessiond::ust::registry_channel
*a
,
584 const lttng::sessiond::ust::registry_channel
*b
) { return a
->id
< b
->id
; });
586 for (const auto stream_class
: sorted_stream_classes
) {
587 stream_class
->accept(visitor
);
592 * Return next available channel id and increment the used counter. The
593 * is_max_channel_id function MUST be called before in order to validate
594 * if the maximum number of IDs have been reached. If not, it is safe to call
597 * Return a unique channel ID. If max is reached, the used_channel_id counter
600 uint32_t lsu::registry_session::_get_next_channel_id()
602 if (is_max_channel_id(_used_channel_id
)) {
603 return _used_channel_id
;
607 return _next_channel_id
++;
610 void lsu::registry_session::_increase_metadata_size(size_t reservation_length
)
612 const auto new_len
= _metadata_len
+ reservation_length
;
613 auto new_alloc_len
= new_len
;
614 const auto old_alloc_len
= _metadata_alloc_len
;
616 /* Rounding the new allocation length to the next power of 2 would overflow. */
617 if (new_alloc_len
> (UINT32_MAX
>> 1)) {
619 "Failed to reserve trace metadata storage as the new size would overflow");
622 /* The current allocation length is already the largest we can afford. */
623 if ((old_alloc_len
<< 1) > (UINT32_MAX
>> 1)) {
625 "Failed to reserve trace metadata storage as the max size was already reached");
628 if (new_alloc_len
> old_alloc_len
) {
630 std::max
<size_t>(1U << get_count_order(new_alloc_len
), old_alloc_len
<< 1);
632 auto newptr
= (char *) realloc(_metadata
, new_alloc_len
);
634 LTTNG_THROW_POSIX("Failed to allocate trace metadata storage", errno
);
639 /* We zero directly the memory from start of allocation. */
640 memset(&_metadata
[old_alloc_len
], 0, new_alloc_len
- old_alloc_len
);
641 _metadata_alloc_len
= new_alloc_len
;
644 _metadata_len
+= reservation_length
;
647 void lsu::registry_session::_append_metadata_fragment(const std::string
& fragment
)
649 const auto offset
= _metadata_len
;
651 _increase_metadata_size(fragment
.size());
652 memcpy(&_metadata
[offset
], fragment
.c_str(), fragment
.size());
654 if (_metadata_fd
>= 0) {
655 const auto bytes_written
=
656 lttng_write(_metadata_fd
, fragment
.c_str(), fragment
.size());
658 if (bytes_written
!= fragment
.size()) {
659 LTTNG_THROW_POSIX("Failed to write trace metadata fragment to file", errno
);
664 void lsu::registry_session::_reset_metadata()
666 _metadata_len_sent
= 0;
667 memset(_metadata
, 0, _metadata_alloc_len
);
670 if (_metadata_fd
> 0) {
671 /* Clear the metadata file's content. */
672 clear_metadata_file(_metadata_fd
);
676 void lsu::registry_session::_generate_metadata()
678 trace_class::accept(*_metadata_generating_visitor
);
681 void lsu::registry_session::regenerate_metadata()
683 lttng::pthread::lock_guard
registry_lock(_lock
);
685 /* Resample the clock */
686 _clock
= lttng::make_unique
<lsu::clock_class
>();
690 _generate_metadata();
694 * Lookup enumeration by enum ID.
696 * Note that there is no need to lock the registry session as this only
697 * performs an RCU-protected look-up. The function also return an rcu-protected
698 * reference, which ensures that the caller keeps the RCU read lock until it
699 * disposes of the object.
701 lsu::registry_enum::const_rcu_protected_reference
702 lsu::registry_session::enumeration(const char *enum_name
, uint64_t enum_id
) const
704 lsu::registry_enum
*reg_enum
= nullptr;
705 struct lttng_ht_node_str
*node
;
706 struct lttng_ht_iter iter
;
707 lttng::urcu::unique_read_lock rcu_lock
;
709 * Hack: only the name is used for hashing; the rest of the attributes
712 lsu::registry_signed_enum
reg_enum_lookup(enum_name
, nullptr, 0);
714 ASSERT_RCU_READ_LOCKED();
716 reg_enum_lookup
.id
= enum_id
;
717 cds_lfht_lookup(_enums
->ht
,
718 ht_hash_enum((void *) ®_enum_lookup
, lttng_ht_seed
),
722 node
= lttng_ht_iter_get_node
<lttng_ht_node_str
>(&iter
);
724 LTTNG_THROW_PROTOCOL_ERROR(lttng::format(
725 "Unknown enumeration referenced by application event field: enum name = `{}`, enum id = {}",
731 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
732 reg_enum
= lttng::utils::container_of(node
, &lsu::registry_enum::node
);
735 return lsu::registry_enum::const_rcu_protected_reference
{ *reg_enum
, std::move(rcu_lock
) };
739 * Lookup enumeration by name and comparing enumeration entries.
740 * Needs to be called from RCU read-side critical section.
743 lsu::registry_session::_lookup_enum(const lsu::registry_enum
*reg_enum_lookup
) const
745 lsu::registry_enum
*reg_enum
= nullptr;
746 struct lttng_ht_node_str
*node
;
747 struct lttng_ht_iter iter
;
749 ASSERT_RCU_READ_LOCKED();
751 cds_lfht_lookup(_enums
->ht
,
752 ht_hash_enum((void *) reg_enum_lookup
, lttng_ht_seed
),
756 node
= lttng_ht_iter_get_node
<lttng_ht_node_str
>(&iter
);
762 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
763 reg_enum
= lttng::utils::container_of(node
, &lsu::registry_enum::node
);
771 * Create a lsu::registry_enum from the given parameters and add it to the
772 * registry hash table, or find it if already there.
774 * Should be called with session registry mutex held.
776 * We receive ownership of entries.
778 void lsu::registry_session::create_or_find_enum(int session_objd
,
779 const char *enum_name
,
780 struct lttng_ust_ctl_enum_entry
*raw_entries
,
784 struct cds_lfht_node
*nodep
;
785 lsu::registry_enum
*reg_enum
= nullptr, *old_reg_enum
;
786 lttng::urcu::read_lock_guard read_lock_guard
;
787 auto entries
= lttng::make_unique_wrapper
<lttng_ust_ctl_enum_entry
, lttng::memory::free
>(
790 LTTNG_ASSERT(enum_name
);
793 * This should not happen but since it comes from the UST tracer, an
794 * external party, don't assert and simply validate values.
796 if (session_objd
< 0) {
797 LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
798 "Invalid parameters used to create or look-up enumeration from registry session: session_objd = {}",
801 if (nr_entries
== 0) {
802 LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
803 "Invalid parameters used to create or look-up enumeration from registry session: nr_entries = {}",
806 if (lttng_strnlen(enum_name
, LTTNG_UST_ABI_SYM_NAME_LEN
) == LTTNG_UST_ABI_SYM_NAME_LEN
) {
807 LTTNG_THROW_INVALID_ARGUMENT_ERROR(
808 "Invalid parameters used to create or look-up enumeration from registry session: enumeration name is not null terminated");
811 if (entries
->start
.signedness
) {
812 reg_enum
= new lsu::registry_signed_enum(enum_name
, entries
.get(), nr_entries
);
814 reg_enum
= new lsu::registry_unsigned_enum(enum_name
, entries
.get(), nr_entries
);
817 old_reg_enum
= _lookup_enum(reg_enum
);
819 DBG("enum %s already in sess_objd: %u", enum_name
, session_objd
);
820 /* Fall through. Use prior enum. */
821 destroy_enum(reg_enum
);
822 reg_enum
= old_reg_enum
;
824 DBG("UST registry creating enum: %s, sess_objd: %u", enum_name
, session_objd
);
825 if (_next_enum_id
== -1ULL) {
826 destroy_enum(reg_enum
);
828 "Failed to allocate unique enumeration ID as it would overflow");
831 reg_enum
->id
= _next_enum_id
++;
832 nodep
= cds_lfht_add_unique(_enums
->ht
,
833 ht_hash_enum(reg_enum
, lttng_ht_seed
),
836 ®_enum
->node
.node
);
837 LTTNG_ASSERT(nodep
== ®_enum
->node
.node
);
840 DBG("UST registry reply with enum %s with id %" PRIu64
" in sess_objd: %u",
844 *enum_id
= reg_enum
->id
;