Clean-up: sessiond rotation: change space to tabs
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-sessiond.h
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
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 <urcu.h>
13#include <urcu/wfcqueue.h>
14
15#include <common/sessiond-comm/sessiond-comm.h>
16#include <common/payload.h>
17#include <common/compat/poll.h>
18#include <common/compat/socket.h>
19#include <common/uuid.h>
20
21#include "session.h"
22#include "ust-app.h"
23#include "notification-thread.h"
24#include "sessiond-config.h"
25
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
36/* Unique identifier of a session daemon instance. */
37extern lttng_uuid sessiond_uuid;
38
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 */
60extern enum consumerd_state ust_consumerd_state;
61extern enum consumerd_state kernel_consumerd_state;
62
63extern const char default_home_dir[],
64 default_tracing_group[],
65 default_ust_sock_dir[],
66 default_global_apps_pipe[];
67
68/* Set in main.c at boot time of the daemon */
69extern struct lttng_kernel_tracer_version kernel_tracer_version;
70extern struct lttng_kernel_tracer_abi_version kernel_tracer_abi_version;
71
72/* Notification thread handle. */
73extern struct notification_thread_handle *notification_thread_handle;
74
75/*
76 * This contains extra data needed for processing a command received by the
77 * session daemon from the lttng client.
78 */
79struct command_ctx {
80 unsigned int lttng_msg_size;
81 struct ltt_session *session;
82 /* Input message */
83 struct lttcomm_session_msg lsm;
84 /* Reply content, starts with an lttcomm_lttng_msg header. */
85 struct lttng_payload reply_payload;
86 lttng_sock_cred creds;
87};
88
89struct ust_command {
90 int sock;
91 struct ust_register_msg reg_msg;
92 struct cds_wfcq_node node;
93};
94
95/*
96 * Queue used to enqueue UST registration request (ust_command) and synchronized
97 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
98 */
99struct ust_cmd_queue {
100 int32_t futex;
101 struct cds_wfcq_head head;
102 struct cds_wfcq_tail tail;
103};
104
105/*
106 * This is the wait queue containing wait nodes during the application
107 * registration process.
108 */
109struct ust_reg_wait_queue {
110 unsigned long count;
111 struct cds_list_head head;
112};
113
114/*
115 * Use by the dispatch registration to queue UST command socket to wait for the
116 * notify socket.
117 */
118struct ust_reg_wait_node {
119 struct ust_app *app;
120 struct cds_list_head head;
121};
122
123/*
124 * Used to notify that a hash table needs to be destroyed by dedicated
125 * thread. Required by design because we don't want to move destroy
126 * paths outside of large RCU read-side lock paths, and destroy cannot
127 * be called by call_rcu thread, because it may hang (waiting for
128 * call_rcu completion).
129 */
130extern int ht_cleanup_pipe[2];
131
132extern int kernel_poll_pipe[2];
133
134/*
135 * Populated when the daemon starts with the current page size of the system.
136 * Set in main() with the current page size.
137 */
138extern long page_size;
139
140/* Application health monitoring */
141extern struct health_app *health_sessiond;
142
143extern struct sessiond_config config;
144
145extern int ust_consumerd64_fd, ust_consumerd32_fd;
146
147/* Parent PID for --sig-parent option */
148extern pid_t ppid;
149/* Internal parent PID use with daemonize. */
150extern pid_t child_ppid;
151
152/* Consumer daemon specific control data. */
153extern struct consumer_data ustconsumer32_data;
154extern struct consumer_data ustconsumer64_data;
155extern struct consumer_data kconsumer_data;
156
157int sessiond_init_thread_quit_pipe(void);
158int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
159int sessiond_wait_for_quit_pipe(int timeout_ms);
160int sessiond_notify_quit_pipe(void);
161void sessiond_close_quit_pipe(void);
162
163int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
164void sessiond_signal_parents(void);
165
166void sessiond_set_client_thread_state(bool running);
167void sessiond_wait_client_thread_stopped(void);
168
169void *thread_manage_consumer(void *data);
170
171#endif /* _LTT_SESSIOND_H */
This page took 0.022637 seconds and 4 git commands to generate.