#include <common/kernel-ctl/kernel-ctl.h>
#include <lttng/notification/channel-internal.h>
#include <lttng/rotate-internal.h>
+#include <lttng/location-internal.h>
+#include <lttng/condition/condition-internal.h>
+#include <lttng/notification/notification-internal.h>
#include "rotation-thread.h"
#include "lttng-sessiond.h"
if (!session->quiet_rotation) {
location = session_get_trace_archive_location(session);
- /* Ownership of location is transferred. */
ret = notification_thread_command_session_rotation_completed(
notification_thread_handle,
session->name,
session->gid,
session->last_archived_chunk_id.value,
location);
+ lttng_trace_archive_location_put(location);
if (ret != LTTNG_OK) {
ERR("Failed to notify notification thread of completed rotation for session %s",
session->name);
session_lock_list();
session = job->session;
if (!session) {
- DBG("Session \"%s\" not found",
- session->name);
/*
* This is a non-fatal error, and we cannot report it to
* the user (timer), so just print the error and
}
static
-int handle_condition(const struct lttng_condition *condition,
- const struct lttng_evaluation *evaluation,
+int handle_condition(const struct lttng_notification *notification,
struct notification_thread_handle *notification_thread_handle)
{
int ret = 0;
enum lttng_evaluation_status evaluation_status;
uint64_t consumed;
struct ltt_session *session;
+ const struct lttng_condition *condition =
+ lttng_notification_get_const_condition(notification);
+ const struct lttng_evaluation *evaluation =
+ lttng_notification_get_const_evaluation(notification);
condition_type = lttng_condition_get_type(condition);
session_lock_list();
session = session_find_by_name(condition_session_name);
if (!session) {
- ret = -1;
- session_unlock_list();
- ERR("Session \"%s\" not found",
+ DBG("Failed to find session while handling notification: notification type = %s, session name = `%s`",
+ lttng_condition_type_str(condition_type),
condition_session_name);
+ /*
+ * Not a fatal error: a session can be destroyed before we get
+ * the chance to handle the notification.
+ */
+ ret = 0;
+ session_unlock_list();
goto end;
}
session_lock(session);
+ if (!lttng_trigger_is_equal(session->rotate_trigger,
+ lttng_notification_get_const_trigger(notification))) {
+ /* Notification does not originate from our rotation trigger. */
+ ret = 0;
+ goto end_unlock;
+ }
+
ret = unsubscribe_session_consumed_size_rotation(session,
notification_thread_handle);
if (ret) {
bool notification_pending;
struct lttng_notification *notification = NULL;
enum lttng_notification_channel_status status;
- const struct lttng_evaluation *notification_evaluation;
- const struct lttng_condition *notification_condition;
status = lttng_notification_channel_has_pending_notification(
rotate_notification_channel, ¬ification_pending);
goto end;
}
- notification_condition = lttng_notification_get_condition(notification);
- notification_evaluation = lttng_notification_get_evaluation(notification);
-
- ret = handle_condition(notification_condition, notification_evaluation,
+ ret = handle_condition(notification,
handle->notification_thread_handle);
end: