Build fix: rpath of test libraries results in non-reproducible build
[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
f6a9efaa 12#include <urcu.h>
8bdee6e2 13#include <urcu/wfcqueue.h>
099e26bd 14
c9e313bc
SM
15#include <common/sessiond-comm/sessiond-comm.hpp>
16#include <common/payload.hpp>
17#include <common/compat/poll.hpp>
18#include <common/compat/socket.hpp>
19#include <common/uuid.hpp>
10a8a223 20
c9e313bc
SM
21#include "session.hpp"
22#include "ust-app.hpp"
23#include "notification-thread.hpp"
24#include "sessiond-config.hpp"
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 36/* Unique identifier of a session daemon instance. */
412d7227 37extern lttng_uuid the_sessiond_uuid;
52a0e931 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 */
412d7227
SM
60extern enum consumerd_state the_ust_consumerd_state;
61extern enum consumerd_state the_kernel_consumerd_state;
917a718d 62
2f77fc4b 63/* Set in main.c at boot time of the daemon */
b8e2fb80
FD
64extern struct lttng_kernel_abi_tracer_version the_kernel_tracer_version;
65extern struct lttng_kernel_abi_tracer_abi_version the_kernel_tracer_abi_version;
2f77fc4b 66
a7333da7 67/* Notification thread handle. */
412d7227 68extern struct notification_thread_handle *the_notification_thread_handle;
e9404c27 69
5461b305
DG
70/*
71 * This contains extra data needed for processing a command received by the
72 * session daemon from the lttng client.
73 */
74struct command_ctx {
5461b305
DG
75 unsigned int lttng_msg_size;
76 struct ltt_session *session;
3a91de3a
JG
77 /* Input message */
78 struct lttcomm_session_msg lsm;
79 /* Reply content, starts with an lttcomm_lttng_msg header. */
80 struct lttng_payload reply_payload;
730389d9 81 lttng_sock_cred creds;
5461b305
DG
82};
83
099e26bd
DG
84struct ust_command {
85 int sock;
86 struct ust_register_msg reg_msg;
8bdee6e2 87 struct cds_wfcq_node node;
099e26bd
DG
88};
89
90/*
7a44d6f1 91 * Queue used to enqueue UST registration request (ust_command) and synchronized
099e26bd
DG
92 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
93 */
94struct ust_cmd_queue {
95 int32_t futex;
8bdee6e2
SM
96 struct cds_wfcq_head head;
97 struct cds_wfcq_tail tail;
099e26bd
DG
98};
99
f45e313d
DG
100/*
101 * This is the wait queue containing wait nodes during the application
102 * registration process.
103 */
104struct ust_reg_wait_queue {
105 unsigned long count;
106 struct cds_list_head head;
107};
108
109/*
110 * Use by the dispatch registration to queue UST command socket to wait for the
111 * notify socket.
112 */
113struct ust_reg_wait_node {
114 struct ust_app *app;
115 struct cds_list_head head;
116};
117
412d7227 118extern int the_kernel_poll_pipe[2];
e32d7f27 119
12744796
DG
120/*
121 * Populated when the daemon starts with the current page size of the system.
a7333da7 122 * Set in main() with the current page size.
12744796 123 */
412d7227 124extern long the_page_size;
12744796 125
5e97de00 126/* Application health monitoring */
412d7227 127extern struct health_app *the_health_sessiond;
5e97de00 128
412d7227 129extern struct sessiond_config the_config;
26296c48 130
412d7227 131extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd;
a7333da7
JG
132
133/* Parent PID for --sig-parent option */
412d7227 134extern pid_t the_ppid;
a7333da7 135/* Internal parent PID use with daemonize. */
412d7227 136extern pid_t the_child_ppid;
e9404c27 137
917a718d 138/* Consumer daemon specific control data. */
412d7227
SM
139extern struct consumer_data the_ustconsumer32_data;
140extern struct consumer_data the_ustconsumer64_data;
141extern struct consumer_data the_kconsumer_data;
917a718d 142
f90a04ed
MJ
143int sessiond_init_main_quit_pipe(void);
144int sessiond_wait_for_main_quit_pipe(int timeout_ms);
145int sessiond_notify_main_quit_pipe(void);
146void sessiond_close_main_quit_pipe(void);
a7333da7 147
5e97de00 148int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
9cc1ba3b 149void sessiond_signal_parents(void);
ef367a93 150
99d688f2
JG
151void sessiond_set_client_thread_state(bool running);
152void sessiond_wait_client_thread_stopped(void);
153
917a718d
JG
154void *thread_manage_consumer(void *data);
155
fac6795d 156#endif /* _LTT_SESSIOND_H */
This page took 0.124285 seconds and 4 git commands to generate.