+ /* Default policy. */
+ policy = lttng_rate_policy_every_n_create(1);
+ if (!policy) {
+ goto end;
+ }
+
+ 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_internal_get_rate_policy,
+ lttng_action_generic_add_error_query_results,
+ lttng_action_notify_mi_serialize);
+
+ notify->policy = policy;
+ policy = NULL;
+
+ action = ¬ify->parent;
+ notify = NULL;
+
+end:
+ free(notify);
+ lttng_rate_policy_destroy(policy);
+ return action;
+}
+
+ssize_t lttng_action_notify_create_from_payload(
+ struct lttng_payload_view *view,
+ struct lttng_action **action)
+{
+ enum lttng_action_status status;
+ ssize_t consumed_length;
+ struct lttng_rate_policy *rate_policy = NULL;
+ struct lttng_action *_action = NULL;
+
+ consumed_length = lttng_rate_policy_create_from_payload(
+ view, &rate_policy);
+ if (!rate_policy) {
+ consumed_length = -1;
+ goto end;
+ }
+
+ _action = lttng_action_notify_create();
+ if (!_action) {
+ consumed_length = -1;
+ goto end;
+ }
+
+ status = lttng_action_notify_set_rate_policy(_action, rate_policy);
+ if (status != LTTNG_ACTION_STATUS_OK) {
+ consumed_length = -1;
+ goto end;
+ }
+
+ *action = _action;
+ _action = NULL;
+
+end:
+ lttng_rate_policy_destroy(rate_policy);
+ lttng_action_destroy(_action);
+ return consumed_length;
+}
+
+enum lttng_action_status lttng_action_notify_set_rate_policy(
+ struct lttng_action *action,
+ const struct lttng_rate_policy *policy)
+{
+ enum lttng_action_status status;
+ struct lttng_action_notify *notify_action;
+ struct lttng_rate_policy *copy = NULL;
+
+ if (!action || !policy || !IS_NOTIFY_ACTION(action)) {
+ status = LTTNG_ACTION_STATUS_INVALID;
+ goto end;
+ }
+
+ copy = lttng_rate_policy_copy(policy);
+ if (!copy) {
+ status = LTTNG_ACTION_STATUS_ERROR;
+ goto end;
+ }
+
+ notify_action = action_notify_from_action(action);
+
+ /* Free the previous rate policy .*/
+ lttng_rate_policy_destroy(notify_action->policy);
+
+ /* Assign the policy. */
+ notify_action->policy = copy;
+ status = LTTNG_ACTION_STATUS_OK;
+ copy = NULL;
+
+end:
+ lttng_rate_policy_destroy(copy);
+ return status;
+}
+
+enum lttng_action_status lttng_action_notify_get_rate_policy(
+ const struct lttng_action *action,
+ const struct lttng_rate_policy **policy)
+{
+ enum lttng_action_status status;
+ const struct lttng_action_notify *notify_action;
+
+ if (!action || !policy || !IS_NOTIFY_ACTION(action)) {
+ status = LTTNG_ACTION_STATUS_INVALID;
+ goto end;
+ }
+
+ notify_action = action_notify_from_action_const(action);
+
+ *policy = notify_action->policy;
+ status = LTTNG_ACTION_STATUS_OK;