SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-sessiond.h
CommitLineData
8c0faa1d 1/*
ab5be9fa
MJ
2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
3 * Copyright (C) 2013 Raphaël Beamonte <raphael.beamonte@gmail.com>
fac6795d 4 *
ab5be9fa 5 * SPDX-License-Identifier: GPL-2.0-only
8c0faa1d 6 *
fac6795d
DG
7 */
8
9#ifndef _LTT_SESSIOND_H
10#define _LTT_SESSIOND_H
11
f6a9efaa 12#include <urcu.h>
8bdee6e2 13#include <urcu/wfcqueue.h>
099e26bd 14
10a8a223 15#include <common/sessiond-comm/sessiond-comm.h>
9e620ea7 16#include <common/payload.h>
d0b96690 17#include <common/compat/poll.h>
730389d9 18#include <common/compat/socket.h>
c70636a7 19#include <common/uuid.h>
10a8a223
DG
20
21#include "session.h"
56fff090 22#include "ust-app.h"
e9404c27 23#include "notification-thread.h"
e6142f2e 24#include "sessiond-config.h"
099e26bd 25
917a718d
JG
26/*
27 * Consumer daemon state which is changed when spawning it, killing it or in
28 * case of a fatal error.
29 */
30enum consumerd_state {
31 CONSUMER_STARTED = 1,
32 CONSUMER_STOPPED = 2,
33 CONSUMER_ERROR = 3,
34};
35
52a0e931
JG
36/* Unique identifier of a session daemon instance. */
37extern lttng_uuid sessiond_uuid;
38
917a718d
JG
39/*
40 * This consumer daemon state is used to validate if a client command will be
41 * able to reach the consumer. If not, the client is informed. For instance,
42 * doing a "lttng start" when the consumer state is set to ERROR will return an
43 * error to the client.
44 *
45 * The following example shows a possible race condition of this scheme:
46 *
47 * consumer thread error happens
48 * client cmd arrives
49 * client cmd checks state -> still OK
50 * consumer thread exit, sets error
51 * client cmd try to talk to consumer
52 * ...
53 *
54 * However, since the consumer is a different daemon, we have no way of making
55 * sure the command will reach it safely even with this state flag. This is why
56 * we consider that up to the state validation during command processing, the
57 * command is safe. After that, we can not guarantee the correctness of the
58 * client request vis-a-vis the consumer.
59 */
60extern enum consumerd_state ust_consumerd_state;
61extern enum consumerd_state kernel_consumerd_state;
62
686204ab
MD
63extern const char default_home_dir[],
64 default_tracing_group[],
65 default_ust_sock_dir[],
66 default_global_apps_pipe[];
fac6795d 67
2f77fc4b 68/* Set in main.c at boot time of the daemon */
917a718d
JG
69extern struct lttng_kernel_tracer_version kernel_tracer_version;
70extern struct lttng_kernel_tracer_abi_version kernel_tracer_abi_version;
2f77fc4b 71
a7333da7 72/* Notification thread handle. */
e9404c27 73extern struct notification_thread_handle *notification_thread_handle;
2463b787 74extern pthread_mutex_t notification_trigger_tokens_ht_lock;
e9404c27 75
5461b305
DG
76/*
77 * This contains extra data needed for processing a command received by the
78 * session daemon from the lttng client.
79 */
80struct command_ctx {
5461b305
DG
81 unsigned int lttng_msg_size;
82 struct ltt_session *session;
3a91de3a
JG
83 /* Input message */
84 struct lttcomm_session_msg lsm;
85 /* Reply content, starts with an lttcomm_lttng_msg header. */
86 struct lttng_payload reply_payload;
730389d9 87 lttng_sock_cred creds;
5461b305
DG
88};
89
099e26bd
DG
90struct ust_command {
91 int sock;
92 struct ust_register_msg reg_msg;
8bdee6e2 93 struct cds_wfcq_node node;
099e26bd
DG
94};
95
96/*
7a44d6f1 97 * Queue used to enqueue UST registration request (ust_command) and synchronized
099e26bd
DG
98 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
99 */
100struct ust_cmd_queue {
101 int32_t futex;
8bdee6e2
SM
102 struct cds_wfcq_head head;
103 struct cds_wfcq_tail tail;
099e26bd
DG
104};
105
f45e313d
DG
106/*
107 * This is the wait queue containing wait nodes during the application
108 * registration process.
109 */
110struct ust_reg_wait_queue {
111 unsigned long count;
112 struct cds_list_head head;
113};
114
115/*
116 * Use by the dispatch registration to queue UST command socket to wait for the
117 * notify socket.
118 */
119struct ust_reg_wait_node {
120 struct ust_app *app;
121 struct cds_list_head head;
122};
123
0b2dc8df
MD
124/*
125 * Used to notify that a hash table needs to be destroyed by dedicated
126 * thread. Required by design because we don't want to move destroy
127 * paths outside of large RCU read-side lock paths, and destroy cannot
128 * be called by call_rcu thread, because it may hang (waiting for
129 * call_rcu completion).
130 */
131extern int ht_cleanup_pipe[2];
132
e32d7f27
JG
133extern int kernel_poll_pipe[2];
134
12744796
DG
135/*
136 * Populated when the daemon starts with the current page size of the system.
a7333da7 137 * Set in main() with the current page size.
12744796
DG
138 */
139extern long page_size;
140
5e97de00
JG
141/* Application health monitoring */
142extern struct health_app *health_sessiond;
143
a7333da7 144extern struct sessiond_config config;
26296c48 145
a7333da7
JG
146extern int ust_consumerd64_fd, ust_consumerd32_fd;
147
148/* Parent PID for --sig-parent option */
149extern pid_t ppid;
150/* Internal parent PID use with daemonize. */
151extern pid_t child_ppid;
e9404c27 152
917a718d
JG
153/* Consumer daemon specific control data. */
154extern struct consumer_data ustconsumer32_data;
155extern struct consumer_data ustconsumer64_data;
156extern struct consumer_data kconsumer_data;
157
a7333da7 158int sessiond_init_thread_quit_pipe(void);
d0b96690 159int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
2d54bfb6 160int sessiond_wait_for_quit_pipe(int timeout_ms);
a7333da7
JG
161int sessiond_notify_quit_pipe(void);
162void sessiond_close_quit_pipe(void);
163
5e97de00 164int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
9cc1ba3b 165void sessiond_signal_parents(void);
ef367a93 166
99d688f2
JG
167void sessiond_set_client_thread_state(bool running);
168void sessiond_wait_client_thread_stopped(void);
169
917a718d
JG
170void *thread_manage_consumer(void *data);
171
fac6795d 172#endif /* _LTT_SESSIOND_H */
This page took 0.139445 seconds and 5 git commands to generate.