X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Factions%2Fsnapshot-session.c;h=776615003a1120073e90f1408c2383299433b94b;hb=588c4b0d153e8919b8d9159b69ce0db8fbe52af0;hp=7c5775eb8da724d298c3b14799e4bd8dc2fbeac9;hpb=d35c7a3876fe55d0b6595c72e83e33d9f24e22c1;p=lttng-tools.git diff --git a/src/common/actions/snapshot-session.c b/src/common/actions/snapshot-session.c index 7c5775eb8..776615003 100644 --- a/src/common/actions/snapshot-session.c +++ b/src/common/actions/snapshot-session.c @@ -13,8 +13,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -36,14 +36,14 @@ struct lttng_action_snapshot_session { * Owned by this. */ struct lttng_snapshot_output *output; - struct lttng_firing_policy *policy; + struct lttng_rate_policy *policy; }; struct lttng_action_snapshot_session_comm { /* All string lengths include the trailing \0. */ uint32_t session_name_len; uint32_t snapshot_output_len; - uint32_t firing_policy_len; + uint32_t rate_policy_len; /* * Variable data (all strings are null-terminated): @@ -55,6 +55,10 @@ struct lttng_action_snapshot_session_comm { char data[]; } LTTNG_PACKED; +static const struct lttng_rate_policy * +lttng_action_snapshot_session_internal_get_rate_policy( + const struct lttng_action *action); + static struct lttng_action_snapshot_session * action_snapshot_session_from_action(struct lttng_action *action) { @@ -123,7 +127,7 @@ static bool lttng_action_snapshot_session_is_equal( goto end; } - is_equal = lttng_firing_policy_is_equal(a->policy, b->policy); + is_equal = lttng_rate_policy_is_equal(a->policy, b->policy); end: return is_equal; } @@ -188,12 +192,12 @@ static int lttng_action_snapshot_session_serialize( payload->buffer.size - size_before_output; } - /* Serialize the firing policy. */ + /* Serialize the rate policy. */ { const size_t size_before_output = payload->buffer.size; struct lttng_action_snapshot_session_comm *comm_in_payload; - ret = lttng_firing_policy_serialize( + ret = lttng_rate_policy_serialize( action_snapshot_session->policy, payload); if (ret) { ret = -1; @@ -202,8 +206,8 @@ static int lttng_action_snapshot_session_serialize( comm_in_payload = (typeof(comm_in_payload))( payload->buffer.data + size_before_comm); - /* Adjust firing policy length in header. */ - comm_in_payload->firing_policy_len = + /* Adjust rate policy length in header. */ + comm_in_payload->rate_policy_len = payload->buffer.size - size_before_output; } @@ -223,7 +227,7 @@ static void lttng_action_snapshot_session_destroy(struct lttng_action *action) free(action_snapshot_session->session_name); lttng_snapshot_output_destroy(action_snapshot_session->output); - lttng_firing_policy_destroy(action_snapshot_session->policy); + lttng_rate_policy_destroy(action_snapshot_session->policy); free(action_snapshot_session); end: @@ -239,7 +243,7 @@ ssize_t lttng_action_snapshot_session_create_from_payload( struct lttng_action *action; enum lttng_action_status status; struct lttng_snapshot_output *snapshot_output = NULL; - struct lttng_firing_policy *policy = NULL; + struct lttng_rate_policy *policy = NULL; const struct lttng_action_snapshot_session_comm *comm; const struct lttng_payload_view snapshot_session_comm_view = lttng_payload_view_from_view( @@ -312,46 +316,46 @@ ssize_t lttng_action_snapshot_session_create_from_payload( variable_data += comm->snapshot_output_len; consumed_len += comm->snapshot_output_len; - /* Firing policy. */ - if (comm->firing_policy_len <= 0) { - ERR("Firing policy should be present."); + /* Rate policy. */ + if (comm->rate_policy_len <= 0) { + ERR("Rate policy should be present."); goto error; } { - ssize_t firing_policy_consumed_len; + ssize_t rate_policy_consumed_len; struct lttng_payload_view policy_view = lttng_payload_view_from_view(view, consumed_len, - comm->firing_policy_len); + comm->rate_policy_len); if (!lttng_payload_view_is_valid(&policy_view)) { - ERR("Failed to create buffer view for firing policy."); + ERR("Failed to create buffer view for rate policy."); goto error; } - firing_policy_consumed_len = - lttng_firing_policy_create_from_payload( + rate_policy_consumed_len = + lttng_rate_policy_create_from_payload( &policy_view, &policy); - if (firing_policy_consumed_len < 0) { + if (rate_policy_consumed_len < 0) { goto error; } - if (firing_policy_consumed_len != comm->firing_policy_len) { - ERR("Failed to deserialize firing policy object: " + if (rate_policy_consumed_len != comm->rate_policy_len) { + ERR("Failed to deserialize rate policy object: " "consumed-len: %zd, expected-len: %" PRIu32, - firing_policy_consumed_len, - comm->firing_policy_len); + rate_policy_consumed_len, + comm->rate_policy_len); goto error; } - status = lttng_action_snapshot_session_set_firing_policy( + status = lttng_action_snapshot_session_set_rate_policy( action, policy); if (status != LTTNG_ACTION_STATUS_OK) { goto error; } } - variable_data += comm->firing_policy_len; - consumed_len += comm->firing_policy_len; + variable_data += comm->rate_policy_len; + consumed_len += comm->rate_policy_len; *p_action = action; action = NULL; @@ -362,7 +366,7 @@ error: consumed_len = -1; end: - lttng_firing_policy_destroy(policy); + lttng_rate_policy_destroy(policy); lttng_action_snapshot_session_destroy(action); lttng_snapshot_output_destroy(snapshot_output); @@ -372,11 +376,11 @@ end: struct lttng_action *lttng_action_snapshot_session_create(void) { struct lttng_action *action = NULL; - struct lttng_firing_policy *policy = NULL; + struct lttng_rate_policy *policy = NULL; enum lttng_action_status status; - /* Create a every N = 1 firing policy. */ - policy = lttng_firing_policy_every_n_create(1); + /* Create a every N = 1 rate policy. */ + policy = lttng_rate_policy_every_n_create(1); if (!policy) { goto end; } @@ -390,10 +394,11 @@ 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_rate_policy, + lttng_action_generic_add_error_query_results); - status = lttng_action_snapshot_session_set_firing_policy( - action, policy); + status = lttng_action_snapshot_session_set_rate_policy(action, policy); if (status != LTTNG_ACTION_STATUS_OK) { free(action); action = NULL; @@ -401,7 +406,7 @@ struct lttng_action *lttng_action_snapshot_session_create(void) } end: - lttng_firing_policy_destroy(policy); + lttng_rate_policy_destroy(policy); return action; } @@ -505,20 +510,20 @@ end: return status; } -enum lttng_action_status lttng_action_snapshot_session_set_firing_policy( +enum lttng_action_status lttng_action_snapshot_session_set_rate_policy( struct lttng_action *action, - const struct lttng_firing_policy *policy) + const struct lttng_rate_policy *policy) { enum lttng_action_status status; struct lttng_action_snapshot_session *snapshot_session_action; - struct lttng_firing_policy *copy = NULL; + struct lttng_rate_policy *copy = NULL; if (!action || !policy || !IS_SNAPSHOT_SESSION_ACTION(action)) { status = LTTNG_ACTION_STATUS_INVALID; goto end; } - copy = lttng_firing_policy_copy(policy); + copy = lttng_rate_policy_copy(policy); if (!copy) { status = LTTNG_ACTION_STATUS_ERROR; goto end; @@ -526,8 +531,8 @@ enum lttng_action_status lttng_action_snapshot_session_set_firing_policy( snapshot_session_action = action_snapshot_session_from_action(action); - /* Free the previous firing policy .*/ - lttng_firing_policy_destroy(snapshot_session_action->policy); + /* Free the previous rate policy .*/ + lttng_rate_policy_destroy(snapshot_session_action->policy); /* Assign the policy. */ snapshot_session_action->policy = copy; @@ -535,13 +540,13 @@ enum lttng_action_status lttng_action_snapshot_session_set_firing_policy( copy = NULL; end: - lttng_firing_policy_destroy(copy); + lttng_rate_policy_destroy(copy); return status; } -enum lttng_action_status lttng_action_snapshot_session_get_firing_policy( +enum lttng_action_status lttng_action_snapshot_session_get_rate_policy( const struct lttng_action *action, - const struct lttng_firing_policy **policy) + const struct lttng_rate_policy **policy) { enum lttng_action_status status; const struct lttng_action_snapshot_session *snapshot_session_action; @@ -559,3 +564,13 @@ enum lttng_action_status lttng_action_snapshot_session_get_firing_policy( end: return status; } + +static const struct lttng_rate_policy * +lttng_action_snapshot_session_internal_get_rate_policy( + const struct lttng_action *action) +{ + const struct lttng_action_snapshot_session *_action; + _action = action_snapshot_session_from_action_const(action); + + return _action->policy; +}