sessiond: open_packets: use user_space_consumer_channel_keys util
[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 79 unsigned int lttng_msg_size;
3a91de3a
JG
80 /* Input message */
81 struct lttcomm_session_msg lsm;
82 /* Reply content, starts with an lttcomm_lttng_msg header. */
83 struct lttng_payload reply_payload;
730389d9 84 lttng_sock_cred creds;
5461b305
DG
85};
86
099e26bd
DG
87struct ust_command {
88 int sock;
89 struct ust_register_msg reg_msg;
8bdee6e2 90 struct cds_wfcq_node node;
099e26bd
DG
91};
92
93/*
7a44d6f1 94 * Queue used to enqueue UST registration request (ust_command) and synchronized
099e26bd
DG
95 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
96 */
97struct ust_cmd_queue {
98 int32_t futex;
8bdee6e2
SM
99 struct cds_wfcq_head head;
100 struct cds_wfcq_tail tail;
099e26bd
DG
101};
102
f45e313d
DG
103/*
104 * This is the wait queue containing wait nodes during the application
105 * registration process.
106 */
107struct ust_reg_wait_queue {
108 unsigned long count;
109 struct cds_list_head head;
110};
111
112/*
113 * Use by the dispatch registration to queue UST command socket to wait for the
114 * notify socket.
115 */
116struct ust_reg_wait_node {
117 struct ust_app *app;
118 struct cds_list_head head;
119};
120
412d7227 121extern int the_kernel_poll_pipe[2];
e32d7f27 122
12744796
DG
123/*
124 * Populated when the daemon starts with the current page size of the system.
a7333da7 125 * Set in main() with the current page size.
12744796 126 */
412d7227 127extern long the_page_size;
12744796 128
5e97de00 129/* Application health monitoring */
412d7227 130extern struct health_app *the_health_sessiond;
5e97de00 131
412d7227 132extern struct sessiond_config the_config;
26296c48 133
412d7227 134extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
a7333da7
JG
135
136/* Parent PID for --sig-parent option */
412d7227 137extern pid_t the_ppid;
a7333da7 138/* Internal parent PID use with daemonize. */
412d7227 139extern pid_t the_child_ppid;
e9404c27 140
917a718d 141/* Consumer daemon specific control data. */
412d7227
SM
142extern struct consumer_data the_ustconsumer32_data;
143extern struct consumer_data the_ustconsumer64_data;
144extern struct consumer_data the_kconsumer_data;
917a718d 145
0f4aa1a8 146int sessiond_init_main_quit_pipe();
f90a04ed 147int sessiond_wait_for_main_quit_pipe(int timeout_ms);
0f4aa1a8
JG
148int sessiond_notify_main_quit_pipe();
149void sessiond_close_main_quit_pipe();
a7333da7 150
5e97de00 151int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
0f4aa1a8 152void sessiond_signal_parents();
ef367a93 153
99d688f2 154void sessiond_set_client_thread_state(bool running);
0f4aa1a8 155void sessiond_wait_client_thread_stopped();
99d688f2 156
917a718d
JG
157void *thread_manage_consumer(void *data);
158
fac6795d 159#endif /* _LTT_SESSIOND_H */
This page took 0.102812 seconds and 5 git commands to generate.