X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Factions%2Faction.cpp;h=5811ef298601b1c77fee81028bd7fc88542ffba9;hb=28ab034a2c3582d07d3423d2d746731f87d3969f;hp=bc9e3580a769632f6f09000eb05318d84501bc24;hpb=52e345b9ac912d033c2a2c25a170a01cf209839d;p=lttng-tools.git diff --git a/src/common/actions/action.cpp b/src/common/actions/action.cpp index bc9e3580a..5811ef298 100644 --- a/src/common/actions/action.cpp +++ b/src/common/actions/action.cpp @@ -7,6 +7,7 @@ #include #include + #include #include #include @@ -45,14 +46,14 @@ enum lttng_action_type lttng_action_get_type(const 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_get_rate_policy_cb get_rate_policy, - action_add_error_query_results_cb add_error_query_results, - action_mi_serialize_cb mi) + enum lttng_action_type type, + action_validate_cb validate, + action_serialize_cb serialize, + action_equal_cb equal, + action_destroy_cb destroy, + action_get_rate_policy_cb get_rate_policy, + action_add_error_query_results_cb add_error_query_results, + action_mi_serialize_cb mi) { urcu_ref_init(&action->ref); action->type = type; @@ -69,11 +70,9 @@ void lttng_action_init(struct lttng_action *action, action->execution_failure_counter = 0; } -static -void action_destroy_ref(struct urcu_ref *ref) +static void action_destroy_ref(struct urcu_ref *ref) { - struct lttng_action *action = - lttng::utils::container_of(ref, <tng_action::ref); + struct lttng_action *action = lttng::utils::container_of(ref, <tng_action::ref); action->destroy(action); } @@ -118,16 +117,14 @@ end: return valid; } -int lttng_action_serialize(struct lttng_action *action, - struct lttng_payload *payload) +int lttng_action_serialize(struct lttng_action *action, struct lttng_payload *payload) { int ret; struct lttng_action_comm action_comm = { .action_type = (int8_t) action->type, }; - ret = lttng_dynamic_buffer_append(&payload->buffer, &action_comm, - sizeof(action_comm)); + ret = lttng_dynamic_buffer_append(&payload->buffer, &action_comm, sizeof(action_comm)); if (ret) { goto end; } @@ -141,14 +138,13 @@ end: } ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view, - struct lttng_action **action) + struct lttng_action **action) { ssize_t consumed_len, specific_action_consumed_len; action_create_from_payload_cb create_from_payload_cb; const struct lttng_action_comm *action_comm; const struct lttng_payload_view action_comm_view = - lttng_payload_view_from_view( - view, 0, sizeof(*action_comm)); + lttng_payload_view_from_view(view, 0, sizeof(*action_comm)); if (!view || !action) { consumed_len = -1; @@ -164,36 +160,31 @@ ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view, action_comm = (const struct lttng_action_comm *) action_comm_view.buffer.data; DBG("Create action from payload: action-type=%s", - lttng_action_type_string((lttng_action_type) action_comm->action_type)); + lttng_action_type_string((lttng_action_type) action_comm->action_type)); switch (action_comm->action_type) { case LTTNG_ACTION_TYPE_NOTIFY: create_from_payload_cb = lttng_action_notify_create_from_payload; break; case LTTNG_ACTION_TYPE_ROTATE_SESSION: - create_from_payload_cb = - lttng_action_rotate_session_create_from_payload; + create_from_payload_cb = lttng_action_rotate_session_create_from_payload; break; case LTTNG_ACTION_TYPE_SNAPSHOT_SESSION: - create_from_payload_cb = - lttng_action_snapshot_session_create_from_payload; + create_from_payload_cb = lttng_action_snapshot_session_create_from_payload; break; case LTTNG_ACTION_TYPE_START_SESSION: - create_from_payload_cb = - lttng_action_start_session_create_from_payload; + create_from_payload_cb = lttng_action_start_session_create_from_payload; break; case LTTNG_ACTION_TYPE_STOP_SESSION: - create_from_payload_cb = - lttng_action_stop_session_create_from_payload; + create_from_payload_cb = lttng_action_stop_session_create_from_payload; break; case LTTNG_ACTION_TYPE_LIST: create_from_payload_cb = lttng_action_list_create_from_payload; break; default: ERR("Failed to create action from payload, unhandled action type: action-type=%u (%s)", - action_comm->action_type, - lttng_action_type_string( - (lttng_action_type) action_comm->action_type)); + action_comm->action_type, + lttng_action_type_string((lttng_action_type) action_comm->action_type)); consumed_len = -1; goto end; } @@ -201,12 +192,10 @@ ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view, { /* Create buffer view for the action-type-specific data. */ struct lttng_payload_view specific_action_view = - lttng_payload_view_from_view(view, - sizeof(struct lttng_action_comm), - -1); + lttng_payload_view_from_view(view, sizeof(struct lttng_action_comm), -1); - specific_action_consumed_len = create_from_payload_cb( - &specific_action_view, action); + specific_action_consumed_len = + create_from_payload_cb(&specific_action_view, action); } if (specific_action_consumed_len < 0) { ERR("Failed to create specific action from buffer."); @@ -216,15 +205,13 @@ ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view, LTTNG_ASSERT(*action); - consumed_len = sizeof(struct lttng_action_comm) + - specific_action_consumed_len; + consumed_len = sizeof(struct lttng_action_comm) + specific_action_consumed_len; end: return consumed_len; } -bool lttng_action_is_equal(const struct lttng_action *a, - const struct lttng_action *b) +bool lttng_action_is_equal(const struct lttng_action *a, const struct lttng_action *b) { bool is_equal = false; @@ -278,39 +265,36 @@ bool lttng_action_should_execute(const struct lttng_action *action) goto end; } - execute = lttng_rate_policy_should_execute( - policy, action->execution_request_counter); + execute = lttng_rate_policy_should_execute(policy, action->execution_request_counter); end: return execute; } -enum lttng_action_status lttng_action_add_error_query_results( - const struct lttng_action *action, - struct lttng_error_query_results *results) +enum lttng_action_status +lttng_action_add_error_query_results(const struct lttng_action *action, + struct lttng_error_query_results *results) { return action->add_error_query_results(action, results); } -enum lttng_action_status lttng_action_generic_add_error_query_results( - const struct lttng_action *action, - struct lttng_error_query_results *results) +enum lttng_action_status +lttng_action_generic_add_error_query_results(const struct lttng_action *action, + struct lttng_error_query_results *results) { enum lttng_action_status action_status; struct lttng_error_query_result *error_counter = NULL; - const uint64_t execution_failure_counter = - uatomic_read(&action->execution_failure_counter); + const uint64_t execution_failure_counter = uatomic_read(&action->execution_failure_counter); error_counter = lttng_error_query_result_counter_create( - "total execution failures", - "Aggregated count of errors encountered when executing the action", - execution_failure_counter); + "total execution failures", + "Aggregated count of errors encountered when executing the action", + execution_failure_counter); if (!error_counter) { action_status = LTTNG_ACTION_STATUS_ERROR; goto end; } - if (lttng_error_query_results_add_result( - results, error_counter)) { + if (lttng_error_query_results_add_result(results, error_counter)) { action_status = LTTNG_ACTION_STATUS_ERROR; goto end; } @@ -323,12 +307,12 @@ end: return action_status; } -enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger, - const struct lttng_action *action, - struct mi_writer *writer, - const struct mi_lttng_error_query_callbacks - *error_query_callbacks, - struct lttng_dynamic_array *action_path_indexes) +enum lttng_error_code +lttng_action_mi_serialize(const struct lttng_trigger *trigger, + const struct lttng_action *action, + struct mi_writer *writer, + const struct mi_lttng_error_query_callbacks *error_query_callbacks, + struct lttng_dynamic_array *action_path_indexes) { int ret; enum lttng_error_code ret_code; @@ -349,8 +333,8 @@ enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trig * Recursion is safe since action lists can't be nested for * the moment. */ - ret_code = lttng_action_list_mi_serialize(trigger, action, writer, - error_query_callbacks, action_path_indexes); + ret_code = lttng_action_list_mi_serialize( + trigger, action, writer, error_query_callbacks, action_path_indexes); if (ret_code != LTTNG_OK) { goto end; } @@ -369,29 +353,25 @@ enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trig if (error_query_callbacks && error_query_callbacks->action_cb) { const uint64_t *action_path_indexes_raw_pointer = NULL; const size_t action_path_indexes_size = - lttng_dynamic_array_get_count( - action_path_indexes); + lttng_dynamic_array_get_count(action_path_indexes); if (action_path_indexes_size != 0) { action_path_indexes_raw_pointer = - (const uint64_t *) action_path_indexes - ->buffer.data; + (const uint64_t *) action_path_indexes->buffer.data; } - action_path = lttng_action_path_create( - action_path_indexes_raw_pointer, - action_path_indexes_size); + action_path = lttng_action_path_create(action_path_indexes_raw_pointer, + action_path_indexes_size); LTTNG_ASSERT(action_path); ret_code = error_query_callbacks->action_cb( - trigger, action_path, &error_query_results); + trigger, action_path, &error_query_results); if (ret_code != LTTNG_OK) { goto end; } /* Serialize the error query results. */ - ret_code = lttng_error_query_results_mi_serialize( - error_query_results, writer); + ret_code = lttng_error_query_results_mi_serialize(error_query_results, writer); if (ret_code != LTTNG_OK) { goto end; }