#include <fcntl.h>
#include <functional>
+#include <initializer_list>
#include <mutex>
#include <sstream>
#include <string>
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
lsu::registry_channel *chan =
- caa_container_of(head, lsu::registry_channel, _rcu_head);
+ lttng::utils::container_of(head, &lsu::registry_channel::_rcu_head);
DIAGNOSTIC_POP
delete chan;
* Destroy every element of the registry and free the memory. This does NOT
* free the registry pointer since it might not have been allocated before so
* it's the caller responsability.
+ *
+ * Called from ~registry_session(), must not throw.
*/
-void destroy_channel(lsu::registry_channel *chan, bool notify)
+void destroy_channel(lsu::registry_channel *chan, bool notify) noexcept
{
struct lttng_ht_iter iter;
lttng::sessiond::ust::registry_event *event;
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
cds_lfht_for_each_entry(
- chan->_events->ht, &iter.iter, event, _node.node) {
+ chan->_events->ht, &iter.iter, event, _node) {
/* Delete the node from the ht and free it. */
ust_registry_channel_destroy_event(chan, event);
}
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
lsu::registry_enum *reg_enum =
- caa_container_of(head, lsu::registry_enum, rcu_head);
+ lttng::utils::container_of(head, &lsu::registry_enum::rcu_head);
DIAGNOSTIC_POP
destroy_enum(reg_enum);
lst::trace_class(in_abi, generate_uuid_or_throw()),
_root_shm_path{root_shm_path ? root_shm_path : ""},
_shm_path{shm_path ? shm_path : ""},
- _metadata_path{_shm_path.size() > 0 ?
- fmt::format("{}/metadata", _shm_path) : std::string("")},
+ _metadata_path{_shm_path.size() > 0 ? fmt::format("{}/metadata", _shm_path) :
+ std::string("")},
_uid{euid},
_gid{egid},
_app_tracer_version{.major = major, .minor = minor},
_tracing_id{tracing_id},
- _metadata_generating_visitor{lttng::make_unique<ls::tsdl::trace_class_visitor>(abi,
- [this](const std::string& fragment) {
+ _clock{lttng::make_unique<lsu::clock_class>()},
+ _metadata_generating_visitor{lttng::make_unique<ls::tsdl::trace_class_visitor>(
+ abi, [this](const std::string& fragment) {
_append_metadata_fragment(fragment);
- })}
+ })},
+ _packet_header{_create_packet_header()}
{
pthread_mutex_init(&_lock, NULL);
if (_shm_path.size() > 0) {
}
}
+lst::type::cuptr lsu::registry_session::_create_packet_header() const
+{
+ lst::structure_type::fields packet_header_fields;
+
+ /* uint32_t magic */
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>("magic",
+ lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
+ abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::HEXADECIMAL,
+ std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_MAGIC_NUMBER}))));
+
+ /* uuid */
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>("uuid",
+ lttng::make_unique<lst::static_length_blob_type>(0, 16,
+ std::initializer_list<lst::static_length_blob_type::role>({lst::static_length_blob_type::role::TRACE_CLASS_UUID}))));
+
+ /* uint32_t stream_id */
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_id",
+ lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
+ abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_CLASS_ID}))));
+
+ /* uint64_t stream_instance_id */
+ packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_instance_id",
+ lttng::make_unique<lst::integer_type>(abi.uint64_t_alignment,
+ abi.byte_order, 64, lst::integer_type::signedness::UNSIGNED,
+ lst::integer_type::base::DECIMAL,
+ std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_ID}))));
+
+ return lttng::make_unique<lst::structure_type>(0, std::move(packet_header_fields));
+}
+
+const lst::type *lsu::registry_session::get_packet_header() const noexcept
+{
+ return _packet_header.get();
+}
+
/*
* For a given enumeration in a registry, delete the entry and destroy
* the enumeration.
+ *
+ * Note that this is used by ~registry_session() and must not throw.
*/
-void lsu::registry_session::_destroy_enum(lsu::registry_enum *reg_enum)
+void lsu::registry_session::_destroy_enum(lsu::registry_enum *reg_enum) noexcept
{
int ret;
lttng::urcu::read_lock_guard read_lock_guard;
}
auto chan = new lsu::registry_channel(
- _get_next_channel_id(),
+ _get_next_channel_id(), abi, _clock->name,
/* Registered channel listener. */
[this](const lsu::registry_channel& registered_channel) {
/*
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- auto chan = caa_container_of(node, lsu::registry_channel, _node);
+ auto chan = lttng::utils::container_of(node, &lsu::registry_channel::_node);
DIAGNOSTIC_POP
return *chan;
}
void lsu::registry_session::_accept_on_clock_classes(lst::trace_class_visitor& visitor) const
{
ASSERT_LOCKED(_lock);
- _clock.accept(visitor);
+ _clock->accept(visitor);
}
void lsu::registry_session::_accept_on_stream_classes(lst::trace_class_visitor& visitor) const
{
lttng::pthread::lock_guard registry_lock(_lock);
+ /* Resample the clock */
+ _clock = lttng::make_unique<lsu::clock_class>();
+
_metadata_version++;
_reset_metadata();
_generate_metadata();
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- reg_enum = caa_container_of(node, lsu::registry_enum, node);
+ reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
DIAGNOSTIC_POP
return lsu::registry_enum::const_rcu_protected_reference{*reg_enum, std::move(rcu_lock)};
DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE_INVALID_OFFSETOF
- reg_enum = caa_container_of(node, lsu::registry_enum, node);
+ reg_enum = lttng::utils::container_of(node, &lsu::registry_enum::node);
DIAGNOSTIC_POP
end:
DBG("UST registry reply with enum %s with id %" PRIu64 " in sess_objd: %u",
enum_name, reg_enum->id, session_objd);
*enum_id = reg_enum->id;
-}
\ No newline at end of file
+}