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