From: Jonathan Rajotte Date: Wed, 7 Apr 2021 13:19:18 +0000 (-0400) Subject: action-executor: consider action firing policy on action execution X-Git-Tag: v2.13.0-rc1~89 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2d57482cbac710612a36b7beae7b59c277006185;p=lttng-tools.git action-executor: consider action firing policy on action execution Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I83f73e905e87a401187e243ed3beafa41964434a --- diff --git a/include/lttng/action/action-internal.h b/include/lttng/action/action-internal.h index 9e43a34d0..1422a6dce 100644 --- a/include/lttng/action/action-internal.h +++ b/include/lttng/action/action-internal.h @@ -18,6 +18,8 @@ #include #include +struct lttng_firing_policy; + typedef bool (*action_validate_cb)(struct lttng_action *action); typedef void (*action_destroy_cb)(struct lttng_action *action); typedef int (*action_serialize_cb)(struct lttng_action *action, @@ -27,6 +29,8 @@ typedef bool (*action_equal_cb)(const struct lttng_action *a, typedef ssize_t (*action_create_from_payload_cb)( struct lttng_payload_view *view, struct lttng_action **action); +typedef const struct lttng_firing_policy *(*action_get_firing_policy_cb)( + const struct lttng_action *action); struct lttng_action { struct urcu_ref ref; @@ -35,6 +39,21 @@ struct lttng_action { action_serialize_cb serialize; action_equal_cb equal; action_destroy_cb destroy; + action_get_firing_policy_cb get_firing_policy; + + /* Internal use only. */ + + /* The number of time the actions was enqueued for execution. */ + uint64_t execution_request_counter; + /* + * The number of time the action was actually executed. + * Action firing policy can impact on this number. + * */ + uint64_t execution_counter; + /* + * The number of time the action execution failed. + */ + uint64_t execution_failure_counter; }; struct lttng_action_comm { @@ -48,7 +67,8 @@ void lttng_action_init(struct lttng_action *action, action_validate_cb validate, action_serialize_cb serialize, action_equal_cb equal, - action_destroy_cb destroy); + action_destroy_cb destroy, + action_get_firing_policy_cb get_firing_policy); LTTNG_HIDDEN bool lttng_action_validate(struct lttng_action *action); @@ -74,4 +94,16 @@ void lttng_action_put(struct lttng_action *action); LTTNG_HIDDEN const char* lttng_action_type_string(enum lttng_action_type action_type); +LTTNG_HIDDEN +void lttng_action_increase_execution_request_count(struct lttng_action *action); + +LTTNG_HIDDEN +void lttng_action_increase_execution_count(struct lttng_action *action); + +LTTNG_HIDDEN +void lttng_action_increase_execution_failure_count(struct lttng_action *action); + +LTTNG_HIDDEN +bool lttng_action_should_execute(const struct lttng_action *action); + #endif /* LTTNG_ACTION_INTERNAL_H */ diff --git a/include/lttng/action/firing-policy-internal.h b/include/lttng/action/firing-policy-internal.h index 0fd62ee99..a6e607676 100644 --- a/include/lttng/action/firing-policy-internal.h +++ b/include/lttng/action/firing-policy-internal.h @@ -33,4 +33,8 @@ LTTNG_HIDDEN struct lttng_firing_policy *lttng_firing_policy_copy( const struct lttng_firing_policy *source); +LTTNG_HIDDEN +bool lttng_firing_policy_should_execute( + const struct lttng_firing_policy *policy, uint64_t counter); + #endif /* LTTNG_FIRING_POLICY */ diff --git a/include/lttng/action/group-internal.h b/include/lttng/action/group-internal.h index cddee55ed..0cb89d54b 100644 --- a/include/lttng/action/group-internal.h +++ b/include/lttng/action/group-internal.h @@ -26,4 +26,8 @@ extern ssize_t lttng_action_group_create_from_payload( struct lttng_payload_view *view, struct lttng_action **group); +LTTNG_HIDDEN +extern struct lttng_action *lttng_action_group_borrow_mutable_at_index( + const struct lttng_action *group, unsigned int index); + #endif /* LTTNG_ACTION_GROUP_INTERNAL_H */ diff --git a/src/bin/lttng-sessiond/action-executor.c b/src/bin/lttng-sessiond/action-executor.c index bce7268e5..6c828c8f0 100644 --- a/src/bin/lttng-sessiond/action-executor.c +++ b/src/bin/lttng-sessiond/action-executor.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -62,29 +63,33 @@ struct action_executor { */ typedef int (*action_executor_handler)(struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *action); + struct lttng_action *action); static int action_executor_notify_handler(struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); -static int action_executor_start_session_handler(struct action_executor *executor, + struct lttng_action *); +static int action_executor_start_session_handler( + struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); -static int action_executor_stop_session_handler(struct action_executor *executor, + struct lttng_action *); +static int action_executor_stop_session_handler( + struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); -static int action_executor_rotate_session_handler(struct action_executor *executor, + struct lttng_action *); +static int action_executor_rotate_session_handler( + struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); -static int action_executor_snapshot_session_handler(struct action_executor *executor, + struct lttng_action *); +static int action_executor_snapshot_session_handler( + struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); + struct lttng_action *); static int action_executor_group_handler(struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); + struct lttng_action *); static int action_executor_generic_handler(struct action_executor *executor, const struct action_work_item *, - const struct lttng_action *); + struct lttng_action *); static const action_executor_handler action_executors[] = { [LTTNG_ACTION_TYPE_NOTIFY] = action_executor_notify_handler, @@ -185,7 +190,7 @@ end: static int action_executor_notify_handler(struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action) + struct lttng_action *action) { return notification_client_list_send_evaluation(work_item->client_list, work_item->trigger, @@ -196,9 +201,10 @@ static int action_executor_notify_handler(struct action_executor *executor, client_handle_transmission_status, executor); } -static int action_executor_start_session_handler(struct action_executor *executor, +static int action_executor_start_session_handler( + struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action) + struct lttng_action *action) { int ret = 0; const char *session_name; @@ -243,6 +249,7 @@ static int action_executor_start_session_handler(struct action_executor *executo WARN("Failed to start session `%s` on behalf of trigger `%s`: %s", session_name, get_trigger_name(work_item->trigger), lttng_strerror(-cmd_ret)); + lttng_action_increase_execution_failure_count(action); break; } @@ -255,9 +262,10 @@ end: return ret; } -static int action_executor_stop_session_handler(struct action_executor *executor, +static int action_executor_stop_session_handler( + struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action) + struct lttng_action *action) { int ret = 0; const char *session_name; @@ -280,6 +288,7 @@ static int action_executor_stop_session_handler(struct action_executor *executor DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`", session_name, get_action_name(action), get_trigger_name(work_item->trigger)); + lttng_action_increase_execution_failure_count(action); goto error_unlock_list; } @@ -302,6 +311,7 @@ static int action_executor_stop_session_handler(struct action_executor *executor WARN("Failed to stop session `%s` on behalf of trigger `%s`: %s", session_name, get_trigger_name(work_item->trigger), lttng_strerror(-cmd_ret)); + lttng_action_increase_execution_failure_count(action); break; } @@ -314,9 +324,10 @@ end: return ret; } -static int action_executor_rotate_session_handler(struct action_executor *executor, +static int action_executor_rotate_session_handler( + struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action) + struct lttng_action *action) { int ret = 0; const char *session_name; @@ -339,6 +350,7 @@ static int action_executor_rotate_session_handler(struct action_executor *execut DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`", session_name, get_action_name(action), get_trigger_name(work_item->trigger)); + lttng_action_increase_execution_failure_count(action); goto error_unlock_list; } @@ -357,6 +369,7 @@ static int action_executor_rotate_session_handler(struct action_executor *execut case LTTNG_ERR_ROTATION_PENDING: DBG("Attempted to start a rotation of session `%s` on behalf of trigger `%s` but a rotation is already ongoing", session_name, get_trigger_name(work_item->trigger)); + lttng_action_increase_execution_failure_count(action); break; case LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP: case LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR: @@ -367,6 +380,7 @@ static int action_executor_rotate_session_handler(struct action_executor *execut WARN("Failed to start a rotation of session `%s` on behalf of trigger `%s`: %s", session_name, get_trigger_name(work_item->trigger), lttng_strerror(-cmd_ret)); + lttng_action_increase_execution_failure_count(action); break; } @@ -379,9 +393,10 @@ end: return ret; } -static int action_executor_snapshot_session_handler(struct action_executor *executor, +static int action_executor_snapshot_session_handler( + struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action) + struct lttng_action *action) { int ret = 0; const char *session_name; @@ -419,6 +434,7 @@ static int action_executor_snapshot_session_handler(struct action_executor *exec DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`", session_name, get_action_name(action), get_trigger_name(work_item->trigger)); + lttng_action_increase_execution_failure_count(action); goto error_unlock_list; } @@ -438,6 +454,7 @@ static int action_executor_snapshot_session_handler(struct action_executor *exec WARN("Failed to record snapshot of session `%s` on behalf of trigger `%s`: %s", session_name, get_trigger_name(work_item->trigger), lttng_strerror(-cmd_ret)); + lttng_action_increase_execution_failure_count(action); break; } @@ -452,7 +469,7 @@ end: static int action_executor_group_handler(struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action_group) + struct lttng_action *action_group) { int ret = 0; unsigned int i, count; @@ -468,8 +485,8 @@ static int action_executor_group_handler(struct action_executor *executor, DBG("Action group has %u action%s", count, count != 1 ? "s" : ""); for (i = 0; i < count; i++) { - const struct lttng_action *action = - lttng_action_group_get_at_index( + struct lttng_action *action = + lttng_action_group_borrow_mutable_at_index( action_group, i); ret = action_executor_generic_handler( @@ -486,27 +503,39 @@ end: static int action_executor_generic_handler(struct action_executor *executor, const struct action_work_item *work_item, - const struct lttng_action *action) + struct lttng_action *action) { + int ret; const enum lttng_action_type action_type = lttng_action_get_type(action); assert(action_type != LTTNG_ACTION_TYPE_UNKNOWN); + lttng_action_increase_execution_request_count(action); + if (!lttng_action_should_execute(action)) { + DBG("Policy prevented execution of action `%s` of trigger `%s` action work item %" PRIu64, + get_action_name(action), + get_trigger_name(work_item->trigger), + work_item->id); + ret = 0; + goto end; + } + + lttng_action_increase_execution_count(action); DBG("Executing action `%s` of trigger `%s` action work item %" PRIu64, get_action_name(action), get_trigger_name(work_item->trigger), work_item->id); - - return action_executors[action_type]( - executor, work_item, action); + ret = action_executors[action_type](executor, work_item, action); +end: + return ret; } static int action_work_item_execute(struct action_executor *executor, struct action_work_item *work_item) { int ret; - const struct lttng_action *action = - lttng_trigger_get_const_action(work_item->trigger); + struct lttng_action *action = + lttng_trigger_get_action(work_item->trigger); DBG("Starting execution of action work item %" PRIu64 " of trigger `%s`", work_item->id, get_trigger_name(work_item->trigger)); diff --git a/src/common/actions/action.c b/src/common/actions/action.c index 95a0c0f4d..07eefeeb0 100644 --- a/src/common/actions/action.c +++ b/src/common/actions/action.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -44,13 +45,13 @@ enum lttng_action_type lttng_action_get_type(const struct lttng_action *action) } LTTNG_HIDDEN -void lttng_action_init( - struct lttng_action *action, +void lttng_action_init(struct lttng_action *action, enum lttng_action_type type, action_validate_cb validate, action_serialize_cb serialize, action_equal_cb equal, - action_destroy_cb destroy) + action_destroy_cb destroy, + action_get_firing_policy_cb get_firing_policy) { urcu_ref_init(&action->ref); action->type = type; @@ -58,6 +59,11 @@ void lttng_action_init( action->serialize = serialize; action->equal = equal; action->destroy = destroy; + action->get_firing_policy = get_firing_policy; + + action->execution_request_counter = 0; + action->execution_counter = 0; + action->execution_failure_counter = 0; } static @@ -243,3 +249,44 @@ bool lttng_action_is_equal(const struct lttng_action *a, end: return is_equal; } + +LTTNG_HIDDEN +void lttng_action_increase_execution_request_count(struct lttng_action *action) +{ + action->execution_request_counter++; +} + +LTTNG_HIDDEN +void lttng_action_increase_execution_count(struct lttng_action *action) +{ + action->execution_counter++; +} + +LTTNG_HIDDEN +void lttng_action_increase_execution_failure_count(struct lttng_action *action) +{ + action->execution_failure_counter++; +} + +LTTNG_HIDDEN +bool lttng_action_should_execute(const struct lttng_action *action) +{ + const struct lttng_firing_policy *policy = NULL; + bool execute = false; + + if (action->get_firing_policy == NULL) { + execute = true; + goto end; + } + + policy = action->get_firing_policy(action); + if (policy == NULL) { + execute = true; + goto end; + } + + execute = lttng_firing_policy_should_execute( + policy, action->execution_request_counter); +end: + return execute; +} diff --git a/src/common/actions/firing-policy.c b/src/common/actions/firing-policy.c index 6152d61d8..8c5a5bffc 100644 --- a/src/common/actions/firing-policy.c +++ b/src/common/actions/firing-policy.c @@ -78,6 +78,14 @@ static void lttng_firing_policy_init(struct lttng_firing_policy *firing_policy, firing_policy_destroy_cb destroy, firing_policy_copy_cb copy); +/* Forward declaration. Every n */ +static bool lttng_firing_policy_every_n_should_execute( + const struct lttng_firing_policy *policy, uint64_t counter); + +/* Forward declaration. Once after N */ +static bool lttng_firing_policy_once_after_n_should_execute( + const struct lttng_firing_policy *policy, uint64_t counter); + LTTNG_HIDDEN const char *lttng_firing_policy_type_string( enum lttng_firing_policy_type firing_policy_type) @@ -319,6 +327,23 @@ end: return is_equal; } +LTTNG_HIDDEN +bool lttng_firing_policy_should_execute( + const struct lttng_firing_policy *policy, uint64_t counter) +{ + switch (policy->type) { + case LTTNG_FIRING_POLICY_TYPE_EVERY_N: + return lttng_firing_policy_every_n_should_execute( + policy, counter); + case LTTNG_FIRING_POLICY_TYPE_ONCE_AFTER_N: + return lttng_firing_policy_once_after_n_should_execute( + policy, counter); + default: + abort(); + break; + } +} + /* Every N */ static const struct lttng_firing_policy_every_n * firing_policy_every_n_from_firing_policy_const( @@ -400,6 +425,13 @@ struct lttng_firing_policy *lttng_firing_policy_every_n_create( { struct lttng_firing_policy_every_n *policy = NULL; + if (interval == 0) { + /* + * An interval of 0 is invalid since it would never be fired. + */ + goto end; + } + policy = zmalloc(sizeof(struct lttng_firing_policy_every_n)); if (!policy) { goto end; @@ -438,6 +470,29 @@ end: return status; } +static bool lttng_firing_policy_every_n_should_execute( + const struct lttng_firing_policy *policy, uint64_t counter) +{ + const struct lttng_firing_policy_every_n *every_n_policy; + assert(policy); + bool execute = false; + + every_n_policy = firing_policy_every_n_from_firing_policy_const(policy); + + if (every_n_policy->interval == 0) { + abort(); + } + + execute = (counter % every_n_policy->interval) == 0; + + DBG("Policy every N = %" PRIu64 + ": execution %s. Execution count: %" PRIu64, + every_n_policy->interval, + execute ? "accepted" : "denied", counter); + + return execute; +} + /* Once after N */ static const struct lttng_firing_policy_once_after_n * @@ -524,6 +579,11 @@ struct lttng_firing_policy *lttng_firing_policy_once_after_n_create( { struct lttng_firing_policy_once_after_n *policy = NULL; + if (threshold == 0) { + /* threshold is expected to be > 0 */ + goto end; + } + policy = zmalloc(sizeof(struct lttng_firing_policy_once_after_n)); if (!policy) { goto end; @@ -571,3 +631,24 @@ struct lttng_firing_policy *lttng_firing_policy_copy( assert(source->copy); return source->copy(source); } + +static bool lttng_firing_policy_once_after_n_should_execute( + const struct lttng_firing_policy *policy, uint64_t counter) +{ + const struct lttng_firing_policy_once_after_n *once_after_n_policy; + bool execute = false; + assert(policy); + + once_after_n_policy = + firing_policy_once_after_n_from_firing_policy_const( + policy); + + execute = counter == once_after_n_policy->threshold; + + DBG("Policy once after N = %" PRIu64 + ": execution %s. Execution count: %" PRIu64, + once_after_n_policy->threshold, + execute ? "accepted" : "denied", counter); + + return counter == once_after_n_policy->threshold; +} diff --git a/src/common/actions/group.c b/src/common/actions/group.c index 4ac239c9d..afb832ee6 100644 --- a/src/common/actions/group.c +++ b/src/common/actions/group.c @@ -266,8 +266,8 @@ struct lttng_action *lttng_action_group_create(void) lttng_action_init(action, LTTNG_ACTION_TYPE_GROUP, lttng_action_group_validate, lttng_action_group_serialize, - lttng_action_group_is_equal, - lttng_action_group_destroy); + lttng_action_group_is_equal, lttng_action_group_destroy, + NULL); lttng_dynamic_pointer_array_init(&action_group->actions, destroy_lttng_action_group_element); @@ -333,10 +333,17 @@ end: const struct lttng_action *lttng_action_group_get_at_index( const struct lttng_action *group, unsigned int index) +{ + return lttng_action_group_borrow_mutable_at_index(group, index); +} + +LTTNG_HIDDEN +struct lttng_action *lttng_action_group_borrow_mutable_at_index( + const struct lttng_action *group, unsigned int index) { unsigned int count; const struct lttng_action_group *action_group; - const struct lttng_action * action = NULL; + struct lttng_action *action = NULL; if (lttng_action_group_get_count(group, &count) != LTTNG_ACTION_STATUS_OK) { diff --git a/src/common/actions/notify.c b/src/common/actions/notify.c index 85029a5e2..3ce1b00f9 100644 --- a/src/common/actions/notify.c +++ b/src/common/actions/notify.c @@ -73,6 +73,16 @@ bool lttng_action_notify_is_equal(const struct lttng_action *a, return lttng_firing_policy_is_equal(_a->policy, _b->policy); } +static const struct lttng_firing_policy * +lttng_action_notify_internal_get_firing_policy( + const struct lttng_action *action) +{ + const struct lttng_action_notify *_action; + _action = action_notify_from_action_const(action); + + return _action->policy; +} + struct lttng_action *lttng_action_notify_create(void) { struct lttng_firing_policy *policy = NULL; @@ -93,7 +103,8 @@ struct lttng_action *lttng_action_notify_create(void) lttng_action_init(¬ify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL, lttng_action_notify_serialize, lttng_action_notify_is_equal, - lttng_action_notify_destroy); + lttng_action_notify_destroy, + lttng_action_notify_internal_get_firing_policy); notify->policy = policy; policy = NULL; diff --git a/src/common/actions/rotate-session.c b/src/common/actions/rotate-session.c index 815e919d8..f2ac2d04d 100644 --- a/src/common/actions/rotate-session.c +++ b/src/common/actions/rotate-session.c @@ -38,6 +38,10 @@ struct lttng_action_rotate_session_comm { char data[]; } LTTNG_PACKED; +static const struct lttng_firing_policy * +lttng_action_rotate_session_internal_get_firing_policy( + const struct lttng_action *action); + static struct lttng_action_rotate_session *action_rotate_session_from_action( struct lttng_action *action) { @@ -247,7 +251,8 @@ struct lttng_action *lttng_action_rotate_session_create(void) lttng_action_rotate_session_validate, lttng_action_rotate_session_serialize, lttng_action_rotate_session_is_equal, - lttng_action_rotate_session_destroy); + lttng_action_rotate_session_destroy, + lttng_action_rotate_session_internal_get_firing_policy); status = lttng_action_rotate_session_set_firing_policy(action, policy); if (status != LTTNG_ACTION_STATUS_OK) { @@ -361,3 +366,13 @@ enum lttng_action_status lttng_action_rotate_session_get_firing_policy( end: return status; } + +static const struct lttng_firing_policy * +lttng_action_rotate_session_internal_get_firing_policy( + const struct lttng_action *action) +{ + const struct lttng_action_rotate_session *_action; + _action = action_rotate_session_from_action_const(action); + + return _action->policy; +} diff --git a/src/common/actions/snapshot-session.c b/src/common/actions/snapshot-session.c index 7c5775eb8..5d0178495 100644 --- a/src/common/actions/snapshot-session.c +++ b/src/common/actions/snapshot-session.c @@ -55,6 +55,10 @@ struct lttng_action_snapshot_session_comm { char data[]; } LTTNG_PACKED; +static const struct lttng_firing_policy * +lttng_action_snapshot_session_internal_get_firing_policy( + const struct lttng_action *action); + static struct lttng_action_snapshot_session * action_snapshot_session_from_action(struct lttng_action *action) { @@ -390,7 +394,8 @@ struct lttng_action *lttng_action_snapshot_session_create(void) lttng_action_snapshot_session_validate, lttng_action_snapshot_session_serialize, lttng_action_snapshot_session_is_equal, - lttng_action_snapshot_session_destroy); + lttng_action_snapshot_session_destroy, + lttng_action_snapshot_session_internal_get_firing_policy); status = lttng_action_snapshot_session_set_firing_policy( action, policy); @@ -559,3 +564,13 @@ enum lttng_action_status lttng_action_snapshot_session_get_firing_policy( end: return status; } + +static const struct lttng_firing_policy * +lttng_action_snapshot_session_internal_get_firing_policy( + const struct lttng_action *action) +{ + const struct lttng_action_snapshot_session *_action; + _action = action_snapshot_session_from_action_const(action); + + return _action->policy; +} diff --git a/src/common/actions/start-session.c b/src/common/actions/start-session.c index 28dc27f82..07aeaf779 100644 --- a/src/common/actions/start-session.c +++ b/src/common/actions/start-session.c @@ -38,6 +38,10 @@ struct lttng_action_start_session_comm { char data[]; } LTTNG_PACKED; +static const struct lttng_firing_policy * +lttng_action_start_session_internal_get_firing_policy( + const struct lttng_action *action); + static struct lttng_action_start_session *action_start_session_from_action( struct lttng_action *action) { @@ -250,7 +254,8 @@ struct lttng_action *lttng_action_start_session_create(void) lttng_action_start_session_validate, lttng_action_start_session_serialize, lttng_action_start_session_is_equal, - lttng_action_start_session_destroy); + lttng_action_start_session_destroy, + lttng_action_start_session_internal_get_firing_policy); status = lttng_action_start_session_set_firing_policy(action, policy); if (status != LTTNG_ACTION_STATUS_OK) { @@ -364,3 +369,13 @@ enum lttng_action_status lttng_action_start_session_get_firing_policy( end: return status; } + +static const struct lttng_firing_policy * +lttng_action_start_session_internal_get_firing_policy( + const struct lttng_action *action) +{ + const struct lttng_action_start_session *_action; + _action = action_start_session_from_action_const(action); + + return _action->policy; +} diff --git a/src/common/actions/stop-session.c b/src/common/actions/stop-session.c index 232bd7265..b3ff63188 100644 --- a/src/common/actions/stop-session.c +++ b/src/common/actions/stop-session.c @@ -38,6 +38,10 @@ struct lttng_action_stop_session_comm { char data[]; } LTTNG_PACKED; +static const struct lttng_firing_policy * +lttng_action_stop_session_internal_get_firing_policy( + const struct lttng_action *action); + static struct lttng_action_stop_session *action_stop_session_from_action( struct lttng_action *action) { @@ -251,7 +255,8 @@ struct lttng_action *lttng_action_stop_session_create(void) lttng_action_stop_session_validate, lttng_action_stop_session_serialize, lttng_action_stop_session_is_equal, - lttng_action_stop_session_destroy); + lttng_action_stop_session_destroy, + lttng_action_stop_session_internal_get_firing_policy); status = lttng_action_stop_session_set_firing_policy(action, policy); if (status != LTTNG_ACTION_STATUS_OK) { @@ -363,3 +368,13 @@ enum lttng_action_status lttng_action_stop_session_get_firing_policy( end: return status; } + +static const struct lttng_firing_policy * +lttng_action_stop_session_internal_get_firing_policy( + const struct lttng_action *action) +{ + const struct lttng_action_stop_session *_action; + _action = action_stop_session_from_action_const(action); + + return _action->policy; +}