#include <lttng/notification/channel-internal.h>
#include <lttng/rotate-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/action/action-internal.h>
#include "session.h"
#include "rotate.h"
int ret;
enum lttng_condition_status condition_status;
enum lttng_notification_channel_status nc_status;
- struct lttng_condition *rotate_condition = NULL;
- struct lttng_action *notify_action = NULL;
- const struct lttng_credentials session_creds = {
- .uid = LTTNG_OPTIONAL_INIT_VALUE(session->uid),
- .gid = LTTNG_OPTIONAL_INIT_VALUE(session->gid),
- };
-
- rotate_condition = lttng_condition_session_consumed_size_create();
- if (!rotate_condition) {
+ struct lttng_action *action;
+
+ session->rotate_condition = lttng_condition_session_consumed_size_create();
+ if (!session->rotate_condition) {
ERR("Failed to create session consumed size condition object");
ret = -1;
goto end;
}
condition_status = lttng_condition_session_consumed_size_set_threshold(
- rotate_condition, size);
+ session->rotate_condition, size);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
ERR("Could not set session consumed size condition threshold (size = %" PRIu64 ")",
size);
condition_status =
lttng_condition_session_consumed_size_set_session_name(
- rotate_condition, session->name);
+ session->rotate_condition, session->name);
if (condition_status != LTTNG_CONDITION_STATUS_OK) {
ERR("Could not set session consumed size condition session name (name = %s)",
session->name);
goto end;
}
- notify_action = lttng_action_notify_create();
- if (!notify_action) {
+ action = lttng_action_notify_create();
+ if (!action) {
ERR("Could not create notify action");
ret = -1;
goto end;
}
- assert(!session->rotate_trigger);
- session->rotate_trigger = lttng_trigger_create(rotate_condition,
- notify_action);
+ session->rotate_trigger = lttng_trigger_create(session->rotate_condition,
+ action);
if (!session->rotate_trigger) {
ERR("Could not create size-based rotation trigger");
ret = -1;
}
nc_status = lttng_notification_channel_subscribe(
- rotate_notification_channel, rotate_condition);
+ rotate_notification_channel, session->rotate_condition);
if (nc_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
ERR("Could not subscribe to session consumed size notification");
ret = -1;
ret = 0;
end:
- lttng_condition_put(rotate_condition);
- lttng_action_put(notify_action);
- if (ret) {
- lttng_trigger_put(session->rotate_trigger);
- }
return ret;
}
int ret = 0;
enum lttng_notification_channel_status status;
- assert(session->rotate_trigger);
status = lttng_notification_channel_unsubscribe(
rotate_notification_channel,
- lttng_trigger_get_const_condition(session->rotate_trigger));
+ session->rotate_condition);
if (status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) {
ERR("Session unsubscribe error: %d", (int) status);
ret = -1;
goto end;
}
- lttng_trigger_put(session->rotate_trigger);
- session->rotate_trigger = NULL;
-
ret = 0;
end:
return ret;
#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"
}
static
-int handle_condition(const struct lttng_notification *notification,
+int handle_condition(const struct lttng_condition *condition,
+ const struct lttng_evaluation *evaluation,
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(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;
}
- ret = handle_condition(notification,
+ notification_condition = lttng_notification_get_condition(notification);
+ notification_evaluation = lttng_notification_get_evaluation(notification);
+
+ ret = handle_condition(notification_condition, notification_evaluation,
handle->notification_thread_handle);
end: