docs: Add supported versions and fix-backport policy
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-sessiond.hpp
CommitLineData
8c0faa1d 1/*
21cf9b6b 2 * Copyright (C) 2011 EfficiOS Inc.
ab5be9fa 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
0038180d
JG
12#include "notification-thread.hpp"
13#include "rotation-thread.hpp"
14#include "session.hpp"
15#include "sessiond-config.hpp"
16#include "ust-app.hpp"
099e26bd 17
c9e313bc
SM
18#include <common/compat/poll.hpp>
19#include <common/compat/socket.hpp>
0038180d
JG
20#include <common/payload.hpp>
21#include <common/sessiond-comm/sessiond-comm.hpp>
c9e313bc 22#include <common/uuid.hpp>
10a8a223 23
0038180d
JG
24#include <urcu.h>
25#include <urcu/wfcqueue.h>
099e26bd 26
917a718d
JG
27/*
28 * Consumer daemon state which is changed when spawning it, killing it or in
29 * case of a fatal error.
30 */
31enum consumerd_state {
32 CONSUMER_STARTED = 1,
33 CONSUMER_STOPPED = 2,
28f23191 34 CONSUMER_ERROR = 3,
917a718d
JG
35};
36
52a0e931 37/* Unique identifier of a session daemon instance. */
412d7227 38extern lttng_uuid the_sessiond_uuid;
52a0e931 39
917a718d
JG
40/*
41 * This consumer daemon state is used to validate if a client command will be
42 * able to reach the consumer. If not, the client is informed. For instance,
43 * doing a "lttng start" when the consumer state is set to ERROR will return an
44 * error to the client.
45 *
46 * The following example shows a possible race condition of this scheme:
47 *
48 * consumer thread error happens
49 * client cmd arrives
50 * client cmd checks state -> still OK
51 * consumer thread exit, sets error
52 * client cmd try to talk to consumer
53 * ...
54 *
55 * However, since the consumer is a different daemon, we have no way of making
56 * sure the command will reach it safely even with this state flag. This is why
57 * we consider that up to the state validation during command processing, the
58 * command is safe. After that, we can not guarantee the correctness of the
59 * client request vis-a-vis the consumer.
60 */
412d7227
SM
61extern enum consumerd_state the_ust_consumerd_state;
62extern enum consumerd_state the_kernel_consumerd_state;
917a718d 63
2f77fc4b 64/* Set in main.c at boot time of the daemon */
b8e2fb80
FD
65extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
66extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
2f77fc4b 67
a7333da7 68/* Notification thread handle. */
412d7227 69extern struct notification_thread_handle *the_notification_thread_handle;
e9404c27 70
0038180d
JG
71/* Rotation thread handle. */
72extern lttng::sessiond::rotation_thread::uptr the_rotation_thread_handle;
73
5461b305
DG
74/*
75 * This contains extra data needed for processing a command received by the
76 * session daemon from the lttng client.
77 */
78struct command_ctx {
5461b305
DG
79 unsigned int lttng_msg_size;
80 struct ltt_session *session;
3a91de3a
JG
81 /* Input message */
82 struct lttcomm_session_msg lsm;
83 /* Reply content, starts with an lttcomm_lttng_msg header. */
84 struct lttng_payload reply_payload;
730389d9 85 lttng_sock_cred creds;
5461b305
DG
86};
87
099e26bd
DG
88struct ust_command {
89 int sock;
90 struct ust_register_msg reg_msg;
8bdee6e2 91 struct cds_wfcq_node node;
099e26bd
DG
92};
93
94/*
7a44d6f1 95 * Queue used to enqueue UST registration request (ust_command) and synchronized
099e26bd
DG
96 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
97 */
98struct ust_cmd_queue {
99 int32_t futex;
8bdee6e2
SM
100 struct cds_wfcq_head head;
101 struct cds_wfcq_tail tail;
099e26bd
DG
102};
103
f45e313d
DG
104/*
105 * This is the wait queue containing wait nodes during the application
106 * registration process.
107 */
108struct ust_reg_wait_queue {
109 unsigned long count;
110 struct cds_list_head head;
111};
112
113/*
114 * Use by the dispatch registration to queue UST command socket to wait for the
115 * notify socket.
116 */
117struct ust_reg_wait_node {
118 struct ust_app *app;
119 struct cds_list_head head;
120};
121
412d7227 122extern int the_kernel_poll_pipe[2];
e32d7f27 123
12744796
DG
124/*
125 * Populated when the daemon starts with the current page size of the system.
a7333da7 126 * Set in main() with the current page size.
12744796 127 */
412d7227 128extern long the_page_size;
12744796 129
5e97de00 130/* Application health monitoring */
412d7227 131extern struct health_app *the_health_sessiond;
5e97de00 132
412d7227 133extern struct sessiond_config the_config;
26296c48 134
412d7227 135extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
a7333da7
JG
136
137/* Parent PID for --sig-parent option */
412d7227 138extern pid_t the_ppid;
a7333da7 139/* Internal parent PID use with daemonize. */
412d7227 140extern pid_t the_child_ppid;
e9404c27 141
917a718d 142/* Consumer daemon specific control data. */
412d7227
SM
143extern struct consumer_data the_ustconsumer32_data;
144extern struct consumer_data the_ustconsumer64_data;
145extern struct consumer_data the_kconsumer_data;
917a718d 146
0f4aa1a8 147int sessiond_init_main_quit_pipe();
f90a04ed 148int sessiond_wait_for_main_quit_pipe(int timeout_ms);
0f4aa1a8
JG
149int sessiond_notify_main_quit_pipe();
150void sessiond_close_main_quit_pipe();
a7333da7 151
5e97de00 152int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
0f4aa1a8 153void sessiond_signal_parents();
ef367a93 154
99d688f2 155void sessiond_set_client_thread_state(bool running);
0f4aa1a8 156void sessiond_wait_client_thread_stopped();
99d688f2 157
917a718d
JG
158void *thread_manage_consumer(void *data);
159
fac6795d 160#endif /* _LTT_SESSIOND_H */
This page took 0.09676 seconds and 4 git commands to generate.