#include "trace-ust.h"
#include "timer.h"
+struct ltt_session_destroy_notifier_element {
+ ltt_session_destroy_notifier notifier;
+ void *user_data;
+};
+
/*
* NOTES:
*
* The caller must hold the session lock.
*/
struct lttng_trace_archive_location *session_get_trace_archive_location(
- struct ltt_session *session)
+ const struct ltt_session *session)
{
int ret;
struct lttng_trace_archive_location *location = NULL;
current_trace_chunk);
}
+static
+void session_notify_destruction(const struct ltt_session *session)
+{
+ size_t i;
+ const size_t count = lttng_dynamic_array_get_count(
+ &session->destroy_notifiers);
+
+ for (i = 0; i < count; i++) {
+ const struct ltt_session_destroy_notifier_element *element =
+ lttng_dynamic_array_get_element(
+ &session->destroy_notifiers, i);
+
+ element->notifier(session, element->user_data);
+ }
+}
+
static
void session_release(struct urcu_ref *ref)
{
usess = session->ust_session;
ksess = session->kernel_session;
+
+ session_notify_destruction(session);
+ lttng_dynamic_array_reset(&session->destroy_notifiers, NULL);
if (session->current_trace_chunk) {
ret = session_close_trace_chunk(session, session->current_trace_chunk);
if (ret) {
session_put(session);
}
+int session_add_destroy_notifier(struct ltt_session *session,
+ ltt_session_destroy_notifier notifier, void *user_data)
+{
+ const struct ltt_session_destroy_notifier_element element = {
+ .notifier = notifier,
+ .user_data = user_data
+ };
+
+ return lttng_dynamic_array_add_element(&session->destroy_notifiers,
+ &element);
+}
+
/*
* Return a ltt_session structure ptr that matches name. If no session found,
* NULL is returned. This must be called with the session list lock held using
goto error;
}
+ lttng_dynamic_array_init(&new_session->destroy_notifiers,
+ sizeof(struct ltt_session_destroy_notifier_element));
urcu_ref_init(&new_session->ref);
pthread_mutex_init(&new_session->lock, NULL);