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-convert.hpp"
17 #include "ust-registry.hpp"
19 #include <common/compat/directory-handle.hpp>
20 #include <common/error.hpp>
21 #include <common/exception.hpp>
22 #include <common/format.hpp>
23 #include <common/hashtable/utils.hpp>
24 #include <common/macros.hpp>
25 #include <common/make-unique.hpp>
26 #include <common/pthread-lock.hpp>
27 #include <common/runas.hpp>
28 #include <common/time.hpp>
29 #include <common/urcu.hpp>
33 #include <initializer_list>
38 namespace ls
= lttng::sessiond
;
39 namespace lst
= lttng::sessiond::trace
;
40 namespace lsu
= lttng::sessiond::ust
;
43 lttng_uuid
generate_uuid_or_throw()
47 if (lttng_uuid_generate(new_uuid
)) {
48 LTTNG_THROW_POSIX("Failed to generate UST uuid", errno
);
54 int get_count_order(unsigned int count
)
58 order
= lttng_fls(count
) - 1;
59 if (count
& (count
- 1)) {
63 LTTNG_ASSERT(order
>= 0);
67 void clear_metadata_file(int fd
)
69 const auto lseek_ret
= lseek(fd
, 0, SEEK_SET
);
72 "Failed to seek to the beginning of the metadata file while clearing it",
76 const auto ret
= ftruncate(fd
, 0);
78 LTTNG_THROW_POSIX("Failed to truncate the metadata file while clearing it", errno
);
83 * Validate that the id has reached the maximum allowed or not.
85 bool is_max_channel_id(uint32_t id
)
87 return id
== UINT32_MAX
;
90 void destroy_channel_rcu(struct rcu_head
*head
)
93 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
94 lsu::registry_channel
*chan
=
95 lttng::utils::container_of(head
, &lsu::registry_channel::_rcu_head
);
102 * Destroy every element of the registry and free the memory. This does NOT
103 * free the registry pointer since it might not have been allocated before so
104 * it's the caller responsability.
106 * Called from ~registry_session(), must not throw.
108 void destroy_channel(lsu::registry_channel
*chan
, bool notify
) noexcept
110 struct lttng_ht_iter iter
;
111 lttng::sessiond::ust::registry_event
*event
;
112 enum lttng_error_code cmd_ret
;
117 cmd_ret
= notification_thread_command_remove_channel(
118 the_notification_thread_handle
, chan
->_consumer_key
, LTTNG_DOMAIN_UST
);
119 if (cmd_ret
!= LTTNG_OK
) {
120 ERR("Failed to remove channel from notification thread");
125 lttng::urcu::read_lock_guard read_lock_guard
;
127 /* Destroy all event associated with this registry. */
129 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
130 cds_lfht_for_each_entry (chan
->_events
->ht
, &iter
.iter
, event
, _node
) {
131 /* Delete the node from the ht and free it. */
132 ust_registry_channel_destroy_event(chan
, event
);
137 call_rcu(&chan
->_rcu_head
, destroy_channel_rcu
);
140 void destroy_enum(lsu::registry_enum
*reg_enum
)
149 void destroy_enum_rcu(struct rcu_head
*head
)
152 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
153 lsu::registry_enum
*reg_enum
=
154 lttng::utils::container_of(head
, &lsu::registry_enum::rcu_head
);
157 destroy_enum(reg_enum
);
161 * Hash table match function for enumerations in the session. Match is
162 * performed on enumeration name, and confirmed by comparing the enum
165 int ht_match_enum(struct cds_lfht_node
*node
, const void *_key
)
167 lsu::registry_enum
*_enum
;
168 const lsu::registry_enum
*key
;
174 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
175 _enum
= caa_container_of(node
, lsu::registry_enum
, node
.node
);
179 key
= (lsu::registry_enum
*) _key
;
181 return *_enum
== *key
;
185 * Hash table match function for enumerations in the session. Match is
186 * performed by enumeration ID.
188 int ht_match_enum_id(struct cds_lfht_node
*node
, const void *_key
)
190 lsu::registry_enum
*_enum
;
191 const lsu::registry_enum
*key
= (lsu::registry_enum
*) _key
;
197 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
198 _enum
= caa_container_of(node
, lsu::registry_enum
, node
.node
);
203 if (_enum
->id
!= key
->id
) {
215 * Hash table hash function for enumerations in the session. The
216 * enumeration name is used for hashing.
218 unsigned long ht_hash_enum(void *_key
, unsigned long seed
)
220 lsu::registry_enum
*key
= (lsu::registry_enum
*) _key
;
223 return hash_key_str(key
->name
.c_str(), seed
);
227 void lsu::details::locked_registry_session_release(lsu::registry_session
*session
)
229 pthread_mutex_unlock(&session
->_lock
);
232 lsu::registry_session::registry_session(const struct lst::abi
& in_abi
,
235 const char *root_shm_path
,
236 const char *shm_path
,
239 uint64_t tracing_id
) :
240 lst::trace_class(in_abi
, generate_uuid_or_throw()),
241 _root_shm_path
{ root_shm_path
? root_shm_path
: "" },
242 _shm_path
{ shm_path
? shm_path
: "" },
243 _metadata_path
{ _shm_path
.size() > 0 ? lttng::format("{}/metadata", _shm_path
) :
247 _app_tracer_version
{ .major
= major
, .minor
= minor
},
248 _tracing_id
{ tracing_id
},
249 _clock
{ lttng::make_unique
<lsu::clock_class
>() },
250 _metadata_generating_visitor
{ lttng::make_unique
<ls::tsdl::trace_class_visitor
>(
252 [this](const std::string
& fragment
) { _append_metadata_fragment(fragment
); }) },
253 _packet_header
{ _create_packet_header() }
255 pthread_mutex_init(&_lock
, nullptr);
256 if (_shm_path
.size() > 0) {
257 if (run_as_mkdir_recursive(_shm_path
.c_str(), S_IRWXU
| S_IRWXG
, euid
, egid
)) {
258 LTTNG_THROW_POSIX("run_as_mkdir_recursive", errno
);
262 if (_metadata_path
.size() > 0) {
263 /* Create metadata file. */
264 const int ret
= run_as_open(_metadata_path
.c_str(),
265 O_WRONLY
| O_CREAT
| O_EXCL
,
272 "Failed to open metadata file during registry session creation: path = {}",
280 _enums
.reset(lttng_ht_new(0, LTTNG_HT_TYPE_STRING
));
282 LTTNG_THROW_POSIX("Failed to create enums hash table", ENOMEM
);
285 /* hash/match functions are specified at call site. */
286 _enums
->match_fct
= nullptr;
287 _enums
->hash_fct
= nullptr;
289 _channels
.reset(lttng_ht_new(0, LTTNG_HT_TYPE_U64
));
291 LTTNG_THROW_POSIX("Failed to create channels hash table", ENOMEM
);
295 lst::type::cuptr
lsu::registry_session::_create_packet_header() const
297 lst::structure_type::fields packet_header_fields
;
300 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
302 lttng::make_unique
<lst::integer_type
>(
303 abi
.uint32_t_alignment
,
306 lst::integer_type::signedness::UNSIGNED
,
307 lst::integer_type::base::HEXADECIMAL
,
308 std::initializer_list
<lst::integer_type::role
>(
309 { lst::integer_type::role::PACKET_MAGIC_NUMBER
}))));
312 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
314 lttng::make_unique
<lst::static_length_blob_type
>(
317 std::initializer_list
<lst::static_length_blob_type::role
>(
318 { lst::static_length_blob_type::role::METADATA_STREAM_UUID
}))));
320 /* uint32_t stream_id */
321 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
323 lttng::make_unique
<lst::integer_type
>(
324 abi
.uint32_t_alignment
,
327 lst::integer_type::signedness::UNSIGNED
,
328 lst::integer_type::base::DECIMAL
,
329 std::initializer_list
<lst::integer_type::role
>(
330 { lst::integer_type::role::DATA_STREAM_CLASS_ID
}))));
332 /* uint64_t stream_instance_id */
333 packet_header_fields
.emplace_back(lttng::make_unique
<lst::field
>(
334 "stream_instance_id",
335 lttng::make_unique
<lst::integer_type
>(
336 abi
.uint64_t_alignment
,
339 lst::integer_type::signedness::UNSIGNED
,
340 lst::integer_type::base::DECIMAL
,
341 std::initializer_list
<lst::integer_type::role
>(
342 { lst::integer_type::role::DATA_STREAM_ID
}))));
344 return lttng::make_unique
<lst::structure_type
>(0, std::move(packet_header_fields
));
347 const lst::type
*lsu::registry_session::packet_header() const noexcept
349 return _packet_header
.get();
353 * For a given enumeration in a registry, delete the entry and destroy
356 * Note that this is used by ~registry_session() and must not throw.
358 void lsu::registry_session::_destroy_enum(lsu::registry_enum
*reg_enum
) noexcept
361 lttng::urcu::read_lock_guard read_lock_guard
;
363 LTTNG_ASSERT(reg_enum
);
364 ASSERT_RCU_READ_LOCKED();
366 /* Delete the node first. */
367 struct lttng_ht_iter iter
;
368 iter
.iter
.node
= ®_enum
->node
.node
;
369 ret
= lttng_ht_del(_enums
.get(), &iter
);
371 call_rcu(®_enum
->rcu_head
, destroy_enum_rcu
);
374 lsu::registry_session::~registry_session()
377 struct lttng_ht_iter iter
;
378 lsu::registry_channel
*chan
;
379 lsu::registry_enum
*reg_enum
;
381 /* On error, EBUSY can be returned if lock. Code flow error. */
382 ret
= pthread_mutex_destroy(&_lock
);
386 lttng::urcu::read_lock_guard read_lock_guard
;
388 /* Destroy all event associated with this registry. */
390 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
391 cds_lfht_for_each_entry (_channels
->ht
, &iter
.iter
, chan
, _node
.node
) {
392 /* Delete the node from the ht and free it. */
393 ret
= lttng_ht_del(_channels
.get(), &iter
);
395 destroy_channel(chan
, true);
401 if (_metadata_fd
>= 0) {
402 ret
= close(_metadata_fd
);
407 ret
= run_as_unlink(_metadata_path
.c_str(), _uid
, _gid
);
413 if (_root_shm_path
[0]) {
414 /* Try to delete the directory hierarchy. */
415 (void) run_as_rmdir_recursive(_root_shm_path
.c_str(),
418 LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG
);
421 /* Destroy the enum hash table */
423 lttng::urcu::read_lock_guard read_lock_guard
;
425 /* Destroy all enum entries associated with this registry. */
427 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
428 cds_lfht_for_each_entry (_enums
->ht
, &iter
.iter
, reg_enum
, node
.node
) {
429 _destroy_enum(reg_enum
);
435 lsu::registry_session::locked_ref
lsu::registry_session::lock() noexcept
437 pthread_mutex_lock(&_lock
);
438 return locked_ref(this);
442 * Initialize registry with default values.
444 void lsu::registry_session::add_channel(uint64_t key
)
446 lttng::pthread::lock_guard
session_lock_guard(_lock
);
449 * Assign a channel ID right now since the event notification comes
450 * *before* the channel notify so the ID needs to be set at this point so
451 * the metadata can be dumped for that event.
453 if (is_max_channel_id(_used_channel_id
)) {
454 LTTNG_THROW_ERROR(lttng::format(
455 "Failed to allocate unique id for channel under session while adding channel"));
458 auto chan
= new lsu::registry_channel(
459 _get_next_channel_id(),
462 /* Registered channel listener. */
463 [this](const lsu::registry_channel
& registered_channel
) {
465 * Channel registration completed, serialize it's layout's
468 registered_channel
.accept(*_metadata_generating_visitor
);
470 /* Added event listener. */
471 [this](const lsu::registry_channel
& channel
,
472 const lsu::registry_event
& added_event
) {
474 * The channel and its event classes will be dumped at once when
475 * it is registered. This check prevents event classes from being
476 * declared before their stream class.
478 if (channel
.is_registered()) {
479 added_event
.accept(*_metadata_generating_visitor
);
483 lttng::urcu::read_lock_guard rcu_read_lock_guard
;
484 lttng_ht_node_init_u64(&chan
->_node
, key
);
485 lttng_ht_add_unique_u64(_channels
.get(), &chan
->_node
);
488 lttng::sessiond::ust::registry_channel
& lsu::registry_session::channel(uint64_t channel_key
) const
490 lttng::urcu::read_lock_guard read_lock_guard
;
491 struct lttng_ht_node_u64
*node
;
492 struct lttng_ht_iter iter
;
494 ASSERT_LOCKED(_lock
);
496 lttng_ht_lookup(_channels
.get(), &channel_key
, &iter
);
497 node
= lttng_ht_iter_get_node_u64(&iter
);
499 LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
500 "Invalid channel key provided: channel key = {}", channel_key
));
504 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
505 auto chan
= lttng::utils::container_of(node
, &lsu::registry_channel::_node
);
510 void lsu::registry_session::remove_channel(uint64_t channel_key
, bool notify
)
512 struct lttng_ht_iter iter
;
514 lttng::urcu::read_lock_guard read_lock_guard
;
516 ASSERT_LOCKED(_lock
);
517 auto& channel_to_remove
= channel(channel_key
);
519 iter
.iter
.node
= &channel_to_remove
._node
.node
;
520 ret
= lttng_ht_del(_channels
.get(), &iter
);
522 destroy_channel(&channel_to_remove
, notify
);
525 void lsu::registry_session::accept(
526 lttng::sessiond::trace::trace_class_environment_visitor
& visitor
) const
528 ASSERT_LOCKED(_lock
);
530 visitor
.visit(lst::environment_field
<const char *>("domain", "ust"));
531 visitor
.visit(lst::environment_field
<const char *>("tracer_name", "lttng-ust"));
532 visitor
.visit(lst::environment_field
<int64_t>("tracer_major", _app_tracer_version
.major
));
533 visitor
.visit(lst::environment_field
<int64_t>("tracer_minor", _app_tracer_version
.minor
));
534 visitor
.visit(lst::environment_field
<const char *>(
535 "tracer_buffering_scheme",
536 buffering_scheme() == LTTNG_BUFFER_PER_PID
? "pid" : "uid"));
537 visitor
.visit(lst::environment_field
<int64_t>("architecture_bit_width", abi
.bits_per_long
));
540 /* The caller already holds the session and session list locks. */
541 ASSERT_SESSION_LIST_LOCKED();
542 const auto session
= ltt_session::find_session(_tracing_id
);
543 ASSERT_LOCKED(session
->_lock
);
545 visitor
.visit(lst::environment_field
<const char *>(
547 session
->has_auto_generated_name
? DEFAULT_SESSION_NAME
: session
->name
));
548 visitor
.visit(lst::environment_field
<std::string
>(
549 "trace_creation_datetime",
550 lttng::utils::time_to_iso8601_str(session
->creation_time
)));
551 visitor
.visit(lst::environment_field
<const char *>("hostname", session
->hostname
));
555 void lsu::registry_session::_accept_on_clock_classes(lst::trace_class_visitor
& visitor
) const
557 ASSERT_LOCKED(_lock
);
558 _clock
->accept(visitor
);
561 void lsu::registry_session::_accept_on_stream_classes(lst::trace_class_visitor
& visitor
) const
563 ASSERT_LOCKED(_lock
);
565 std::vector
<const lttng::sessiond::ust::registry_channel
*> sorted_stream_classes
;
568 lttng::urcu::read_lock_guard rcu_lock_guard
;
569 const lsu::registry_channel
*channel
;
570 lttng_ht_iter channel_it
;
573 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
574 cds_lfht_for_each_entry (_channels
->ht
, &channel_it
.iter
, channel
, _node
.node
) {
575 sorted_stream_classes
.emplace_back(channel
);
580 std::sort(sorted_stream_classes
.begin(),
581 sorted_stream_classes
.end(),
582 [](const lttng::sessiond::ust::registry_channel
*a
,
583 const lttng::sessiond::ust::registry_channel
*b
) { return a
->id
< b
->id
; });
585 for (const auto stream_class
: sorted_stream_classes
) {
586 stream_class
->accept(visitor
);
591 * Return next available channel id and increment the used counter. The
592 * is_max_channel_id function MUST be called before in order to validate
593 * if the maximum number of IDs have been reached. If not, it is safe to call
596 * Return a unique channel ID. If max is reached, the used_channel_id counter
599 uint32_t lsu::registry_session::_get_next_channel_id()
601 if (is_max_channel_id(_used_channel_id
)) {
602 return _used_channel_id
;
606 return _next_channel_id
++;
609 void lsu::registry_session::_increase_metadata_size(size_t reservation_length
)
611 const auto new_len
= _metadata_len
+ reservation_length
;
612 auto new_alloc_len
= new_len
;
613 const auto old_alloc_len
= _metadata_alloc_len
;
615 /* Rounding the new allocation length to the next power of 2 would overflow. */
616 if (new_alloc_len
> (UINT32_MAX
>> 1)) {
618 "Failed to reserve trace metadata storage as the new size would overflow");
621 /* The current allocation length is already the largest we can afford. */
622 if ((old_alloc_len
<< 1) > (UINT32_MAX
>> 1)) {
624 "Failed to reserve trace metadata storage as the max size was already reached");
627 if (new_alloc_len
> old_alloc_len
) {
629 std::max
<size_t>(1U << get_count_order(new_alloc_len
), old_alloc_len
<< 1);
631 auto newptr
= (char *) realloc(_metadata
, new_alloc_len
);
633 LTTNG_THROW_POSIX("Failed to allocate trace metadata storage", errno
);
638 /* We zero directly the memory from start of allocation. */
639 memset(&_metadata
[old_alloc_len
], 0, new_alloc_len
- old_alloc_len
);
640 _metadata_alloc_len
= new_alloc_len
;
643 _metadata_len
+= reservation_length
;
646 void lsu::registry_session::_append_metadata_fragment(const std::string
& fragment
)
648 const auto offset
= _metadata_len
;
650 _increase_metadata_size(fragment
.size());
651 memcpy(&_metadata
[offset
], fragment
.c_str(), fragment
.size());
653 if (_metadata_fd
>= 0) {
654 const auto bytes_written
=
655 lttng_write(_metadata_fd
, fragment
.c_str(), fragment
.size());
657 if (bytes_written
!= fragment
.size()) {
658 LTTNG_THROW_POSIX("Failed to write trace metadata fragment to file", errno
);
663 void lsu::registry_session::_reset_metadata()
665 _metadata_len_sent
= 0;
666 memset(_metadata
, 0, _metadata_alloc_len
);
669 if (_metadata_fd
> 0) {
670 /* Clear the metadata file's content. */
671 clear_metadata_file(_metadata_fd
);
675 void lsu::registry_session::_generate_metadata()
677 trace_class::accept(*_metadata_generating_visitor
);
680 void lsu::registry_session::regenerate_metadata()
682 lttng::pthread::lock_guard
registry_lock(_lock
);
684 /* Resample the clock */
685 _clock
= lttng::make_unique
<lsu::clock_class
>();
689 _generate_metadata();
693 * Lookup enumeration by enum ID.
695 * Note that there is no need to lock the registry session as this only
696 * performs an RCU-protected look-up. The function also return an rcu-protected
697 * reference, which ensures that the caller keeps the RCU read lock until it
698 * disposes of the object.
700 lsu::registry_enum::const_rcu_protected_reference
701 lsu::registry_session::enumeration(const char *enum_name
, uint64_t enum_id
) const
703 lsu::registry_enum
*reg_enum
= nullptr;
704 struct lttng_ht_node_str
*node
;
705 struct lttng_ht_iter iter
;
706 lttng::urcu::unique_read_lock rcu_lock
;
708 * Hack: only the name is used for hashing; the rest of the attributes
711 lsu::registry_signed_enum
reg_enum_lookup(enum_name
, nullptr, 0);
713 ASSERT_RCU_READ_LOCKED();
715 reg_enum_lookup
.id
= enum_id
;
716 cds_lfht_lookup(_enums
->ht
,
717 ht_hash_enum((void *) ®_enum_lookup
, lttng_ht_seed
),
721 node
= lttng_ht_iter_get_node_str(&iter
);
723 LTTNG_THROW_PROTOCOL_ERROR(lttng::format(
724 "Unknown enumeration referenced by application event field: enum name = `{}`, enum id = {}",
730 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
731 reg_enum
= lttng::utils::container_of(node
, &lsu::registry_enum::node
);
734 return lsu::registry_enum::const_rcu_protected_reference
{ *reg_enum
, std::move(rcu_lock
) };
738 * Lookup enumeration by name and comparing enumeration entries.
739 * Needs to be called from RCU read-side critical section.
742 lsu::registry_session::_lookup_enum(const lsu::registry_enum
*reg_enum_lookup
) const
744 lsu::registry_enum
*reg_enum
= nullptr;
745 struct lttng_ht_node_str
*node
;
746 struct lttng_ht_iter iter
;
748 ASSERT_RCU_READ_LOCKED();
750 cds_lfht_lookup(_enums
->ht
,
751 ht_hash_enum((void *) reg_enum_lookup
, lttng_ht_seed
),
755 node
= lttng_ht_iter_get_node_str(&iter
);
761 DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
762 reg_enum
= lttng::utils::container_of(node
, &lsu::registry_enum::node
);
770 * Create a lsu::registry_enum from the given parameters and add it to the
771 * registry hash table, or find it if already there.
773 * Should be called with session registry mutex held.
775 * We receive ownership of entries.
777 void lsu::registry_session::create_or_find_enum(int session_objd
,
778 const char *enum_name
,
779 struct lttng_ust_ctl_enum_entry
*raw_entries
,
783 struct cds_lfht_node
*nodep
;
784 lsu::registry_enum
*reg_enum
= nullptr, *old_reg_enum
;
785 lttng::urcu::read_lock_guard read_lock_guard
;
786 auto entries
= lttng::make_unique_wrapper
<lttng_ust_ctl_enum_entry
, lttng::memory::free
>(
789 LTTNG_ASSERT(enum_name
);
792 * This should not happen but since it comes from the UST tracer, an
793 * external party, don't assert and simply validate values.
795 if (session_objd
< 0) {
796 LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
797 "Invalid parameters used to create or look-up enumeration from registry session: session_objd = {}",
800 if (nr_entries
== 0) {
801 LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format(
802 "Invalid parameters used to create or look-up enumeration from registry session: nr_entries = {}",
805 if (lttng_strnlen(enum_name
, LTTNG_UST_ABI_SYM_NAME_LEN
) == LTTNG_UST_ABI_SYM_NAME_LEN
) {
806 LTTNG_THROW_INVALID_ARGUMENT_ERROR(
807 "Invalid parameters used to create or look-up enumeration from registry session: enumeration name is not null terminated");
810 if (entries
->start
.signedness
) {
811 reg_enum
= new lsu::registry_signed_enum(enum_name
, entries
.get(), nr_entries
);
813 reg_enum
= new lsu::registry_unsigned_enum(enum_name
, entries
.get(), nr_entries
);
816 old_reg_enum
= _lookup_enum(reg_enum
);
818 DBG("enum %s already in sess_objd: %u", enum_name
, session_objd
);
819 /* Fall through. Use prior enum. */
820 destroy_enum(reg_enum
);
821 reg_enum
= old_reg_enum
;
823 DBG("UST registry creating enum: %s, sess_objd: %u", enum_name
, session_objd
);
824 if (_next_enum_id
== -1ULL) {
825 destroy_enum(reg_enum
);
827 "Failed to allocate unique enumeration ID as it would overflow");
830 reg_enum
->id
= _next_enum_id
++;
831 nodep
= cds_lfht_add_unique(_enums
->ht
,
832 ht_hash_enum(reg_enum
, lttng_ht_seed
),
835 ®_enum
->node
.node
);
836 LTTNG_ASSERT(nodep
== ®_enum
->node
.node
);
839 DBG("UST registry reply with enum %s with id %" PRIu64
" in sess_objd: %u",
843 *enum_id
= reg_enum
->id
;