X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fsession.hpp;h=12ac3eb73f78e39afc3a982df278b869a88bc081;hb=d7bfb9b0fa35679d3e728b9165699d9faf905539;hp=85450b66a73e19facbd965e6d9b6e1c849497f31;hpb=c9e313bc594f40a86eed237dce222c0fc99c957f;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/session.hpp b/src/bin/lttng-sessiond/session.hpp index 85450b66a..12ac3eb73 100644 --- a/src/bin/lttng-sessiond/session.hpp +++ b/src/bin/lttng-sessiond/session.hpp @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include #include @@ -22,6 +24,8 @@ #include "trace-kernel.hpp" #include "consumer.hpp" +#define ASSERT_SESSION_LIST_LOCKED() LTTNG_ASSERT(session_trylock_list()) + struct ltt_ust_session; typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session, @@ -29,6 +33,14 @@ typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session, typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session, void *user_data); +namespace lttng { +namespace sessiond { +namespace details { +void locked_session_release(ltt_session *session); +} /* namespace details */ +} /* namespace sessiond */ +} /* namespace lttng */ + /* * Tracing session list * @@ -65,6 +77,12 @@ struct ltt_session_list { * session for both LTTng and UST. */ struct ltt_session { + using id_t = uint64_t; + using locked_ptr = std::unique_ptr::deleter>; + using sptr = std::shared_ptr; + char name[NAME_MAX]; bool has_auto_generated_name; bool name_contains_creation_time; @@ -82,7 +100,8 @@ struct ltt_session { */ pthread_mutex_t lock; struct cds_list_head list; - uint64_t id; /* session unique identifier */ + /* session unique identifier */ + id_t id; /* Indicates if the session has been added to the session list and ht.*/ bool published; /* Indicates if a destroy command has been applied to this session. */ @@ -181,9 +200,8 @@ struct ltt_session { */ bool rotated; /* - * Condition and trigger for size-based rotations. + * Trigger for size-based rotations. */ - struct lttng_condition *rotate_condition; struct lttng_trigger *rotate_trigger; LTTNG_OPTIONAL(uint64_t) most_recent_chunk_id; struct lttng_trace_chunk *current_trace_chunk; @@ -239,7 +257,7 @@ struct lttng_trace_archive_location *session_get_trace_archive_location( const struct ltt_session *session); struct ltt_session *session_find_by_name(const char *name); -struct ltt_session *session_find_by_id(uint64_t id); +struct ltt_session *session_find_by_id(ltt_session::id_t id); struct ltt_session_list *session_get_list(void); void session_list_wait_empty(void); @@ -293,4 +311,26 @@ bool session_output_supports_trace_chunks(const struct ltt_session *session); */ bool sample_session_id_by_name(const char *name, uint64_t *id); +namespace lttng { +namespace sessiond { + +/* + * Session list lock must be acquired by the caller. + * The caller must not keep the ownership of the returned locked session + * for longer than strictly necessary. If your intention is to acquire + * a reference to an ltt_session, see `find_session_by_id()`. + */ +ltt_session::locked_ptr find_locked_session_by_id(ltt_session::id_t id); + +/* + * Session list lock must be acquired by the caller. + * The caller must not keep the ownership of the returned locked session + * for longer than strictly necessary. If your intention is to acquire + * a reference to an ltt_session, see `find_session_by_id()`. + */ +ltt_session::sptr find_session_by_id(ltt_session::id_t id); + +} /* namespace sessiond */ +} /* namespace lttng */ + #endif /* _LTT_SESSION_H */