Clean-up: apply suggested clang-tidy fixes
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-sessiond.hpp
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 EfficiOS Inc.
3 * Copyright (C) 2013 Raphaƫl Beamonte <raphael.beamonte@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 */
8
9#ifndef _LTT_SESSIOND_H
10#define _LTT_SESSIOND_H
11
12#include "notification-thread.hpp"
13#include "rotation-thread.hpp"
14#include "session.hpp"
15#include "sessiond-config.hpp"
16#include "ust-app.hpp"
17
18#include <common/compat/poll.hpp>
19#include <common/compat/socket.hpp>
20#include <common/payload.hpp>
21#include <common/sessiond-comm/sessiond-comm.hpp>
22#include <common/uuid.hpp>
23
24#include <urcu.h>
25#include <urcu/wfcqueue.h>
26
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,
34 CONSUMER_ERROR = 3,
35};
36
37/* Unique identifier of a session daemon instance. */
38extern lttng_uuid the_sessiond_uuid;
39
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 */
61extern enum consumerd_state the_ust_consumerd_state;
62extern enum consumerd_state the_kernel_consumerd_state;
63
64/* Set in main.c at boot time of the daemon */
65extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
66extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
67
68/* Notification thread handle. */
69extern struct notification_thread_handle *the_notification_thread_handle;
70
71/* Rotation thread handle. */
72extern lttng::sessiond::rotation_thread::uptr the_rotation_thread_handle;
73
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 {
79 unsigned int lttng_msg_size;
80 struct ltt_session *session;
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;
85 lttng_sock_cred creds;
86};
87
88struct ust_command {
89 int sock;
90 struct ust_register_msg reg_msg;
91 struct cds_wfcq_node node;
92};
93
94/*
95 * Queue used to enqueue UST registration request (ust_command) and synchronized
96 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
97 */
98struct ust_cmd_queue {
99 int32_t futex;
100 struct cds_wfcq_head head;
101 struct cds_wfcq_tail tail;
102};
103
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
122extern int the_kernel_poll_pipe[2];
123
124/*
125 * Populated when the daemon starts with the current page size of the system.
126 * Set in main() with the current page size.
127 */
128extern long the_page_size;
129
130/* Application health monitoring */
131extern struct health_app *the_health_sessiond;
132
133extern struct sessiond_config the_config;
134
135extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
136
137/* Parent PID for --sig-parent option */
138extern pid_t the_ppid;
139/* Internal parent PID use with daemonize. */
140extern pid_t the_child_ppid;
141
142/* Consumer daemon specific control data. */
143extern struct consumer_data the_ustconsumer32_data;
144extern struct consumer_data the_ustconsumer64_data;
145extern struct consumer_data the_kconsumer_data;
146
147int sessiond_init_main_quit_pipe();
148int sessiond_wait_for_main_quit_pipe(int timeout_ms);
149int sessiond_notify_main_quit_pipe();
150void sessiond_close_main_quit_pipe();
151
152int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
153void sessiond_signal_parents();
154
155void sessiond_set_client_thread_state(bool running);
156void sessiond_wait_client_thread_stopped();
157
158void *thread_manage_consumer(void *data);
159
160#endif /* _LTT_SESSIOND_H */
This page took 0.022614 seconds and 4 git commands to generate.