Fix: sessiond: size-based rotation threshold exceeded in per-pid tracing (1/2)
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-commands.hpp
CommitLineData
ab0ee2ca 1/*
ab5be9fa 2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
ab0ee2ca 3 *
ab5be9fa 4 * SPDX-License-Identifier: GPL-2.0-only
ab0ee2ca 5 *
ab0ee2ca
JG
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>
c9e313bc
SM
14#include "notification-thread.hpp"
15#include "notification-thread-internal.hpp"
16#include "notification-thread-events.hpp"
17#include <common/waiter.hpp>
0ab399e0 18#include <stdbool.h>
ab0ee2ca
JG
19
20struct notification_thread_data;
21struct lttng_trigger;
22
23enum 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,
139a8d25
JG
28 NOTIFICATION_COMMAND_TYPE_ADD_SESSION,
29 NOTIFICATION_COMMAND_TYPE_REMOVE_SESSION,
731c1b12
JG
30 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_ONGOING,
31 NOTIFICATION_COMMAND_TYPE_SESSION_ROTATION_COMPLETED,
d02d7404
JR
32 NOTIFICATION_COMMAND_TYPE_ADD_TRACER_EVENT_SOURCE,
33 NOTIFICATION_COMMAND_TYPE_REMOVE_TRACER_EVENT_SOURCE,
fbc9f37d 34 NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS,
ab0ee2ca 35 NOTIFICATION_COMMAND_TYPE_QUIT,
f2b3ef9f 36 NOTIFICATION_COMMAND_TYPE_CLIENT_COMMUNICATION_UPDATE,
8790759c 37 NOTIFICATION_COMMAND_TYPE_GET_TRIGGER,
ab0ee2ca
JG
38};
39
ab0ee2ca
JG
40struct notification_thread_command {
41 struct cds_list_head cmd_list_node;
42
43 enum notification_thread_command_type type;
44 union {
ac16173e
JG
45 /* Register trigger. */
46 struct {
47 struct lttng_trigger *trigger;
0efb2ad7 48 bool is_trigger_anonymous;
ac16173e
JG
49 } register_trigger;
50 /* Unregister trigger. */
51 struct {
52 const struct lttng_trigger *trigger;
53 } unregister_trigger;
139a8d25
JG
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;
ab0ee2ca 65 /* Add channel. */
8abe313a
JG
66 struct {
67 struct {
139a8d25 68 uint64_t id;
8abe313a
JG
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;
ab0ee2ca
JG
77 /* Remove channel. */
78 struct {
79 uint64_t key;
80 enum lttng_domain_type domain;
81 } remove_channel;
731c1b12 82 struct {
139a8d25 83 uint64_t session_id;
731c1b12 84 uint64_t trace_archive_chunk_id;
d3740619 85 /* Weak reference. */
731c1b12
JG
86 struct lttng_trace_archive_location *location;
87 } session_rotation;
d02d7404
JR
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;
fbc9f37d
JR
93 /* List triggers. */
94 struct {
95 /* Credentials of the requesting user. */
96 uid_t uid;
97 } list_triggers;
f2b3ef9f
JG
98 /* Client communication update. */
99 struct {
100 notification_client_id id;
101 enum client_transmission_status status;
102 } client_communication_update;
103
8790759c
FD
104 struct {
105 const struct lttng_trigger *trigger;
106 } get_trigger;
107
ab0ee2ca
JG
108 } parameters;
109
fbc9f37d
JR
110 union {
111 struct {
112 struct lttng_triggers *triggers;
113 } list_triggers;
8790759c
FD
114 struct {
115 struct lttng_trigger *trigger;
116 } get_trigger;
fbc9f37d 117 } reply;
8ada111f
JG
118 /* lttng_waiter on which to wait for command reply (optional). */
119 struct lttng_waiter reply_waiter;
ab0ee2ca 120 enum lttng_error_code reply_code;
0ab399e0 121 bool is_async;
ab0ee2ca
JG
122};
123
124enum lttng_error_code notification_thread_command_register_trigger(
125 struct notification_thread_handle *handle,
0efb2ad7
JG
126 struct lttng_trigger *trigger,
127 bool is_anonymous_trigger);
ab0ee2ca
JG
128
129enum lttng_error_code notification_thread_command_unregister_trigger(
130 struct notification_thread_handle *handle,
ac16173e 131 const struct lttng_trigger *trigger);
ab0ee2ca 132
139a8d25
JG
133enum 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
140enum lttng_error_code notification_thread_command_remove_session(
141 struct notification_thread_handle *handle,
142 uint64_t session_id);
143
ab0ee2ca
JG
144enum lttng_error_code notification_thread_command_add_channel(
145 struct notification_thread_handle *handle,
139a8d25 146 uint64_t session_id,
ab0ee2ca
JG
147 char *channel_name, uint64_t key,
148 enum lttng_domain_type domain, uint64_t capacity);
149
150enum lttng_error_code notification_thread_command_remove_channel(
151 struct notification_thread_handle *handle,
152 uint64_t key, enum lttng_domain_type domain);
153
731c1b12
JG
154enum lttng_error_code notification_thread_command_session_rotation_ongoing(
155 struct notification_thread_handle *handle,
139a8d25 156 uint64_t session_id,
731c1b12
JG
157 uint64_t trace_archive_chunk_id);
158
159/* Ownership of location is transferred. */
160enum lttng_error_code notification_thread_command_session_rotation_completed(
161 struct notification_thread_handle *handle,
139a8d25 162 uint64_t session_id,
731c1b12
JG
163 uint64_t trace_archive_chunk_id,
164 struct lttng_trace_archive_location *location);
165
fbc9f37d
JR
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 */
179enum 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
d02d7404
JR
184/*
185 * The ownership of trigger_event_application_pipe is _not_ transferred to
186 * the notification thread.
187 */
188enum 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
193enum lttng_error_code notification_thread_command_remove_tracer_event_source(
194 struct notification_thread_handle *handle,
195 int tracer_event_source_fd);
196
ab0ee2ca
JG
197void notification_thread_command_quit(
198 struct notification_thread_handle *handle);
199
8790759c
FD
200enum 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
ab0ee2ca 205#endif /* NOTIFICATION_THREAD_COMMANDS_H */
This page took 0.061328 seconds and 4 git commands to generate.