Fix: sessiond: size-based rotation threshold exceeded in per-pid tracing (1/2)
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-commands.hpp
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef NOTIFICATION_THREAD_COMMANDS_H
9 #define NOTIFICATION_THREAD_COMMANDS_H
10
11 #include <lttng/domain.h>
12 #include <lttng/lttng-error.h>
13 #include <urcu/rculfhash.h>
14 #include "notification-thread.hpp"
15 #include "notification-thread-internal.hpp"
16 #include "notification-thread-events.hpp"
17 #include <common/waiter.hpp>
18 #include <stdbool.h>
19
20 struct notification_thread_data;
21 struct lttng_trigger;
22
23 enum notification_thread_command_type {
24 NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER,
25 NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER,
26 NOTIFICATION_COMMAND_TYPE_ADD_CHANNEL,
27 NOTIFICATION_COMMAND_TYPE_REMOVE_CHANNEL,
28 NOTIFICATION_COMMAND_TYPE_ADD_SESSION,
29 NOTIFICATION_COMMAND_TYPE_REMOVE_SESSION,
30 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
31 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
32 NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
33 NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
34 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
35 NOTIFICATION_COMMAND_TYPE_QUIT,
36 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
37 NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
38 };
39
40 struct notification_thread_command {
41 struct cds_list_head cmd_list_node;
42
43 enum notification_thread_command_type type;
44 union {
45 /* Register trigger. */
46 struct {
47 struct lttng_trigger *trigger;
48 bool is_trigger_anonymous;
49 } register_trigger;
50 /* Unregister trigger. */
51 struct {
52 const struct lttng_trigger *trigger;
53 } unregister_trigger;
54 /* Add session. */
55 struct {
56 uint64_t session_id;
57 const char *session_name;
58 uid_t session_uid;
59 gid_t session_gid;
60 } add_session;
61 /* Remove session. */
62 struct {
63 uint64_t session_id;
64 } remove_session;
65 /* Add channel. */
66 struct {
67 struct {
68 uint64_t id;
69 } session;
70 struct {
71 const char *name;
72 enum lttng_domain_type domain;
73 uint64_t key;
74 uint64_t capacity;
75 } channel;
76 } add_channel;
77 /* Remove channel. */
78 struct {
79 uint64_t key;
80 enum lttng_domain_type domain;
81 } remove_channel;
82 struct {
83 uint64_t session_id;
84 uint64_t trace_archive_chunk_id;
85 /* Weak reference. */
86 struct lttng_trace_archive_location *location;
87 } session_rotation;
88 /* Add/Remove tracer event source fd. */
89 struct {
90 int tracer_event_source_fd;
91 enum lttng_domain_type domain;
92 } tracer_event_source;
93 /* List triggers. */
94 struct {
95 /* Credentials of the requesting user. */
96 uid_t uid;
97 } list_triggers;
98 /* Client communication update. */
99 struct {
100 notification_client_id id;
101 enum client_transmission_status status;
102 } client_communication_update;
103
104 struct {
105 const struct lttng_trigger *trigger;
106 } get_trigger;
107
108 } parameters;
109
110 union {
111 struct {
112 struct lttng_triggers *triggers;
113 } list_triggers;
114 struct {
115 struct lttng_trigger *trigger;
116 } get_trigger;
117 } reply;
118 /* lttng_waiter on which to wait for command reply (optional). */
119 struct lttng_waiter reply_waiter;
120 enum lttng_error_code reply_code;
121 bool is_async;
122 };
123
124 enum lttng_error_code notification_thread_command_register_trigger(
125 struct notification_thread_handle *handle,
126 struct lttng_trigger *trigger,
127 bool is_anonymous_trigger);
128
129 enum lttng_error_code notification_thread_command_unregister_trigger(
130 struct notification_thread_handle *handle,
131 const struct lttng_trigger *trigger);
132
133 enum lttng_error_code notification_thread_command_add_session(
134 struct notification_thread_handle *handle,
135 uint64_t session_id,
136 const char *session_name,
137 uid_t session_uid,
138 gid_t session_gid);
139
140 enum lttng_error_code notification_thread_command_remove_session(
141 struct notification_thread_handle *handle,
142 uint64_t session_id);
143
144 enum lttng_error_code notification_thread_command_add_channel(
145 struct notification_thread_handle *handle,
146 uint64_t session_id,
147 char *channel_name, uint64_t key,
148 enum lttng_domain_type domain, uint64_t capacity);
149
150 enum lttng_error_code notification_thread_command_remove_channel(
151 struct notification_thread_handle *handle,
152 uint64_t key, enum lttng_domain_type domain);
153
154 enum lttng_error_code notification_thread_command_session_rotation_ongoing(
155 struct notification_thread_handle *handle,
156 uint64_t session_id,
157 uint64_t trace_archive_chunk_id);
158
159 /* Ownership of location is transferred. */
160 enum lttng_error_code notification_thread_command_session_rotation_completed(
161 struct notification_thread_handle *handle,
162 uint64_t session_id,
163 uint64_t trace_archive_chunk_id,
164 struct lttng_trace_archive_location *location);
165
166 /*
167 * Return the set of triggers visible to a given client.
168 *
169 * The trigger objects contained in the set are the actual trigger instances
170 * used by the notification subsystem (i.e. not a copy). Given that the command
171 * is only used to serialize the triggers, this is fine: the properties that
172 * are serialized are immutable over the lifetime of the triggers.
173 *
174 * Moreover, the lifetime of the trigger instances is protected through
175 * reference counting (references are held by the trigger set).
176 *
177 * The caller has the exclusive ownership of the returned trigger set.
178 */
179 enum lttng_error_code notification_thread_command_list_triggers(
180 struct notification_thread_handle *handle,
181 uid_t client_uid,
182 struct lttng_triggers **triggers);
183
184 /*
185 * The ownership of trigger_event_application_pipe is _not_ transferred to
186 * the notification thread.
187 */
188 enum lttng_error_code notification_thread_command_add_tracer_event_source(
189 struct notification_thread_handle *handle,
190 int tracer_event_source_fd,
191 enum lttng_domain_type domain);
192
193 enum lttng_error_code notification_thread_command_remove_tracer_event_source(
194 struct notification_thread_handle *handle,
195 int tracer_event_source_fd);
196
197 void notification_thread_command_quit(
198 struct notification_thread_handle *handle);
199
200 enum lttng_error_code notification_thread_command_get_trigger(
201 struct notification_thread_handle *handle,
202 const struct lttng_trigger *trigger,
203 struct lttng_trigger **real_trigger);
204
205 #endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.03296 seconds and 4 git commands to generate.