sessiond: implement EXECUTE_ERROR_QUERY command
[lttng-tools.git] / include / lttng / action / action-internal.h
CommitLineData
a58c490f 1/*
ab5be9fa 2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
a58c490f 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
a58c490f 5 *
a58c490f
JG
6 */
7
8#ifndef LTTNG_ACTION_INTERNAL_H
9#define LTTNG_ACTION_INTERNAL_H
10
a58c490f 11#include <common/buffer-view.h>
3647288f 12#include <common/dynamic-buffer.h>
588c4b0d 13#include <common/macros.h>
9e620ea7
JG
14#include <common/payload-view.h>
15#include <common/payload.h>
588c4b0d
JG
16#include <lttng/lttng.h>
17#include <pthread.h>
a58c490f 18#include <stdbool.h>
72756a3f 19#include <sys/types.h>
c852ce4e 20#include <urcu/ref.h>
a58c490f 21
7f4d5b07 22struct lttng_rate_policy;
2d57482c 23
a58c490f
JG
24typedef bool (*action_validate_cb)(struct lttng_action *action);
25typedef void (*action_destroy_cb)(struct lttng_action *action);
3647288f 26typedef int (*action_serialize_cb)(struct lttng_action *action,
c0a66c84 27 struct lttng_payload *payload);
3dd04a6a
JR
28typedef bool (*action_equal_cb)(const struct lttng_action *a,
29 const struct lttng_action *b);
c0a66c84
JG
30typedef ssize_t (*action_create_from_payload_cb)(
31 struct lttng_payload_view *view,
869a3c2d 32 struct lttng_action **action);
7f4d5b07 33typedef const struct lttng_rate_policy *(*action_get_rate_policy_cb)(
2d57482c 34 const struct lttng_action *action);
588c4b0d
JG
35typedef enum lttng_action_status (*action_add_error_query_results_cb)(
36 const struct lttng_action *action,
37 struct lttng_error_query_results *results);
a58c490f
JG
38
39struct lttng_action {
c852ce4e 40 struct urcu_ref ref;
a58c490f
JG
41 enum lttng_action_type type;
42 action_validate_cb validate;
43 action_serialize_cb serialize;
3dd04a6a 44 action_equal_cb equal;
a58c490f 45 action_destroy_cb destroy;
7f4d5b07 46 action_get_rate_policy_cb get_rate_policy;
588c4b0d 47 action_add_error_query_results_cb add_error_query_results;
2d57482c
JR
48
49 /* Internal use only. */
50
51 /* The number of time the actions was enqueued for execution. */
52 uint64_t execution_request_counter;
53 /*
54 * The number of time the action was actually executed.
7f4d5b07 55 * Action rate policy can impact on this number.
2d57482c
JR
56 * */
57 uint64_t execution_counter;
58 /*
59 * The number of time the action execution failed.
588c4b0d
JG
60 * An unsigned long is used to use a type which makes atomic
61 * operations possible.
2d57482c 62 */
588c4b0d 63 unsigned long execution_failure_counter;
a58c490f
JG
64};
65
66struct lttng_action_comm {
67 /* enum lttng_action_type */
68 int8_t action_type;
69} LTTNG_PACKED;
70
6acb3f46
SM
71LTTNG_HIDDEN
72void lttng_action_init(struct lttng_action *action,
73 enum lttng_action_type type,
74 action_validate_cb validate,
75 action_serialize_cb serialize,
3dd04a6a 76 action_equal_cb equal,
2d57482c 77 action_destroy_cb destroy,
588c4b0d
JG
78 action_get_rate_policy_cb get_rate_policy,
79 action_add_error_query_results_cb add_error_query_results);
6acb3f46 80
a58c490f
JG
81LTTNG_HIDDEN
82bool lttng_action_validate(struct lttng_action *action);
83
84LTTNG_HIDDEN
3647288f 85int lttng_action_serialize(struct lttng_action *action,
c0a66c84 86 struct lttng_payload *buf);
a58c490f
JG
87
88LTTNG_HIDDEN
c0a66c84 89ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
a58c490f
JG
90 struct lttng_action **action);
91
3dd04a6a
JR
92LTTNG_HIDDEN
93bool lttng_action_is_equal(const struct lttng_action *a,
94 const struct lttng_action *b);
95
c852ce4e
JG
96LTTNG_HIDDEN
97void lttng_action_get(struct lttng_action *action);
98
99LTTNG_HIDDEN
100void lttng_action_put(struct lttng_action *action);
101
10615eee
JR
102LTTNG_HIDDEN
103const char* lttng_action_type_string(enum lttng_action_type action_type);
104
2d57482c
JR
105LTTNG_HIDDEN
106void lttng_action_increase_execution_request_count(struct lttng_action *action);
107
108LTTNG_HIDDEN
109void lttng_action_increase_execution_count(struct lttng_action *action);
110
111LTTNG_HIDDEN
112void lttng_action_increase_execution_failure_count(struct lttng_action *action);
113
114LTTNG_HIDDEN
115bool lttng_action_should_execute(const struct lttng_action *action);
116
588c4b0d
JG
117LTTNG_HIDDEN
118enum lttng_action_status lttng_action_add_error_query_results(
119 const struct lttng_action *action,
120 struct lttng_error_query_results *results);
121
122/*
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 group, which passes-through) provide.
126 */
127LTTNG_HIDDEN
128enum lttng_action_status lttng_action_generic_add_error_query_results(
129 const struct lttng_action *action,
130 struct lttng_error_query_results *results);
131
a58c490f 132#endif /* LTTNG_ACTION_INTERNAL_H */
This page took 0.035802 seconds and 4 git commands to generate.