2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_ACTION_INTERNAL_H
9 #define LTTNG_ACTION_INTERNAL_H
11 #include <common/buffer-view.h>
12 #include <common/dynamic-buffer.h>
13 #include <common/macros.h>
14 #include <common/payload-view.h>
15 #include <common/payload.h>
16 #include <lttng/lttng.h>
19 #include <sys/types.h>
22 struct lttng_rate_policy
;
24 typedef bool (*action_validate_cb
)(struct lttng_action
*action
);
25 typedef void (*action_destroy_cb
)(struct lttng_action
*action
);
26 typedef int (*action_serialize_cb
)(struct lttng_action
*action
,
27 struct lttng_payload
*payload
);
28 typedef bool (*action_equal_cb
)(const struct lttng_action
*a
,
29 const struct lttng_action
*b
);
30 typedef ssize_t (*action_create_from_payload_cb
)(
31 struct lttng_payload_view
*view
,
32 struct lttng_action
**action
);
33 typedef const struct lttng_rate_policy
*(*action_get_rate_policy_cb
)(
34 const struct lttng_action
*action
);
35 typedef enum lttng_action_status (*action_add_error_query_results_cb
)(
36 const struct lttng_action
*action
,
37 struct lttng_error_query_results
*results
);
41 enum lttng_action_type type
;
42 action_validate_cb validate
;
43 action_serialize_cb serialize
;
44 action_equal_cb equal
;
45 action_destroy_cb destroy
;
46 action_get_rate_policy_cb get_rate_policy
;
47 action_add_error_query_results_cb add_error_query_results
;
49 /* Internal use only. */
51 /* The number of time the actions was enqueued for execution. */
52 uint64_t execution_request_counter
;
54 * The number of time the action was actually executed.
55 * Action rate policy can impact on this number.
57 uint64_t execution_counter
;
59 * The number of time the action execution failed.
60 * An unsigned long is used to use a type which makes atomic
61 * operations possible.
63 unsigned long execution_failure_counter
;
66 struct lttng_action_comm
{
67 /* enum lttng_action_type */
72 void lttng_action_init(struct lttng_action
*action
,
73 enum lttng_action_type type
,
74 action_validate_cb validate
,
75 action_serialize_cb serialize
,
76 action_equal_cb equal
,
77 action_destroy_cb destroy
,
78 action_get_rate_policy_cb get_rate_policy
,
79 action_add_error_query_results_cb add_error_query_results
);
82 bool lttng_action_validate(struct lttng_action
*action
);
85 int lttng_action_serialize(struct lttng_action
*action
,
86 struct lttng_payload
*buf
);
89 ssize_t
lttng_action_create_from_payload(struct lttng_payload_view
*view
,
90 struct lttng_action
**action
);
93 bool lttng_action_is_equal(const struct lttng_action
*a
,
94 const struct lttng_action
*b
);
97 void lttng_action_get(struct lttng_action
*action
);
100 void lttng_action_put(struct lttng_action
*action
);
103 const char* lttng_action_type_string(enum lttng_action_type action_type
);
106 void lttng_action_increase_execution_request_count(struct lttng_action
*action
);
109 void lttng_action_increase_execution_count(struct lttng_action
*action
);
112 void lttng_action_increase_execution_failure_count(struct lttng_action
*action
);
115 bool lttng_action_should_execute(const struct lttng_action
*action
);
118 enum lttng_action_status
lttng_action_add_error_query_results(
119 const struct lttng_action
*action
,
120 struct lttng_error_query_results
*results
);
123 * For use by the various lttng_action implementation. Implements the default
124 * behavior to the generic error "execution failure counter" that all actions
125 * (except list, which passes-through) provide.
128 enum lttng_action_status
lttng_action_generic_add_error_query_results(
129 const struct lttng_action
*action
,
130 struct lttng_error_query_results
*results
);
132 #endif /* LTTNG_ACTION_INTERNAL_H */