void *user_data;
};
+struct ltt_session_clear_notifier_element {
+ ltt_session_clear_notifier notifier;
+ void *user_data;
+};
+
/*
* NOTES:
*
}
}
+/*
+ * Fire each clear notifier once, and remove them from the array.
+ */
+void session_notify_clear(struct ltt_session *session)
+{
+ size_t i;
+ const size_t count = lttng_dynamic_array_get_count(
+ &session->clear_notifiers);
+
+ for (i = 0; i < count; i++) {
+ const struct ltt_session_clear_notifier_element *element =
+ lttng_dynamic_array_get_element(
+ &session->clear_notifiers, i);
+
+ element->notifier(session, element->user_data);
+ }
+ lttng_dynamic_array_clear(&session->clear_notifiers);
+}
+
static
void session_release(struct urcu_ref *ref)
{
session->ust_session = NULL;
}
lttng_dynamic_array_reset(&session->destroy_notifiers);
+ lttng_dynamic_array_reset(&session->clear_notifiers);
free(session->last_archived_chunk_name);
free(session->base_path);
free(session);
&element);
}
+int session_add_clear_notifier(struct ltt_session *session,
+ ltt_session_clear_notifier notifier, void *user_data)
+{
+ const struct ltt_session_clear_notifier_element element = {
+ .notifier = notifier,
+ .user_data = user_data
+ };
+
+ return lttng_dynamic_array_add_element(&session->clear_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
lttng_dynamic_array_init(&new_session->destroy_notifiers,
sizeof(struct ltt_session_destroy_notifier_element),
NULL);
+ lttng_dynamic_array_init(&new_session->clear_notifiers,
+ sizeof(struct ltt_session_clear_notifier_element),
+ NULL);
urcu_ref_init(&new_session->ref);
pthread_mutex_init(&new_session->lock, NULL);
chunk_id);
lttng_trace_chunk_put(session->chunk_being_archived);
session->chunk_being_archived = NULL;
+ /*
+ * Fire the clear reply notifiers if we are completing a clear
+ * rotation.
+ */
+ session_notify_clear(session);
}
return ret;
}
typedef void (*ltt_session_destroy_notifier)(const struct ltt_session *session,
void *user_data);
+typedef void (*ltt_session_clear_notifier)(const struct ltt_session *session,
+ void *user_data);
/*
* Tracing session list
char *last_archived_chunk_name;
LTTNG_OPTIONAL(uint64_t) last_archived_chunk_id;
struct lttng_dynamic_array destroy_notifiers;
+ struct lttng_dynamic_array clear_notifiers;
/* Session base path override. Set non-null. */
char *base_path;
};
int session_add_destroy_notifier(struct ltt_session *session,
ltt_session_destroy_notifier notifier, void *user_data);
+int session_add_clear_notifier(struct ltt_session *session,
+ ltt_session_clear_notifier notifier, void *user_data);
+void session_notify_clear(struct ltt_session *session);
+
bool session_get(struct ltt_session *session);
void session_put(struct ltt_session *session);