Generate a UUID on lttng-sessiond launch
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-sessiond.h
CommitLineData
8c0faa1d
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
88564da0 3 * Copyright (C) 2013 - Raphaël Beamonte <raphael.beamonte@gmail.com>
fac6795d 4 *
d14d33bf
AM
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as published by the Free Software Foundation.
8c0faa1d 8 *
fac6795d
DG
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d14d33bf 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fac6795d 12 * GNU General Public License for more details.
8c0faa1d 13 *
d14d33bf
AM
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
fac6795d
DG
17 */
18
19#ifndef _LTT_SESSIOND_H
20#define _LTT_SESSIOND_H
21
f6a9efaa 22#include <urcu.h>
8bdee6e2 23#include <urcu/wfcqueue.h>
099e26bd 24
10a8a223 25#include <common/sessiond-comm/sessiond-comm.h>
d0b96690 26#include <common/compat/poll.h>
730389d9 27#include <common/compat/socket.h>
52a0e931 28#include <common/compat/uuid.h>
10a8a223
DG
29
30#include "session.h"
56fff090 31#include "ust-app.h"
e9404c27 32#include "notification-thread.h"
e6142f2e 33#include "sessiond-config.h"
099e26bd 34
917a718d
JG
35/*
36 * Consumer daemon state which is changed when spawning it, killing it or in
37 * case of a fatal error.
38 */
39enum consumerd_state {
40 CONSUMER_STARTED = 1,
41 CONSUMER_STOPPED = 2,
42 CONSUMER_ERROR = 3,
43};
44
52a0e931
JG
45/* Unique identifier of a session daemon instance. */
46extern lttng_uuid sessiond_uuid;
47
917a718d
JG
48/*
49 * This consumer daemon state is used to validate if a client command will be
50 * able to reach the consumer. If not, the client is informed. For instance,
51 * doing a "lttng start" when the consumer state is set to ERROR will return an
52 * error to the client.
53 *
54 * The following example shows a possible race condition of this scheme:
55 *
56 * consumer thread error happens
57 * client cmd arrives
58 * client cmd checks state -> still OK
59 * consumer thread exit, sets error
60 * client cmd try to talk to consumer
61 * ...
62 *
63 * However, since the consumer is a different daemon, we have no way of making
64 * sure the command will reach it safely even with this state flag. This is why
65 * we consider that up to the state validation during command processing, the
66 * command is safe. After that, we can not guarantee the correctness of the
67 * client request vis-a-vis the consumer.
68 */
69extern enum consumerd_state ust_consumerd_state;
70extern enum consumerd_state kernel_consumerd_state;
71
686204ab
MD
72extern const char default_home_dir[],
73 default_tracing_group[],
74 default_ust_sock_dir[],
75 default_global_apps_pipe[];
fac6795d 76
2f77fc4b
DG
77/* Set in main.c at boot time of the daemon */
78extern int kernel_tracer_fd;
917a718d
JG
79extern struct lttng_kernel_tracer_version kernel_tracer_version;
80extern struct lttng_kernel_tracer_abi_version kernel_tracer_abi_version;
2f77fc4b 81
a7333da7 82/* Notification thread handle. */
e9404c27
JG
83extern struct notification_thread_handle *notification_thread_handle;
84
5461b305
DG
85/*
86 * This contains extra data needed for processing a command received by the
87 * session daemon from the lttng client.
88 */
89struct command_ctx {
90 int ust_sock;
91 unsigned int lttng_msg_size;
92 struct ltt_session *session;
93 struct lttcomm_lttng_msg *llm;
94 struct lttcomm_session_msg *lsm;
730389d9 95 lttng_sock_cred creds;
5461b305
DG
96};
97
099e26bd
DG
98struct ust_command {
99 int sock;
100 struct ust_register_msg reg_msg;
8bdee6e2 101 struct cds_wfcq_node node;
099e26bd
DG
102};
103
104/*
7a44d6f1 105 * Queue used to enqueue UST registration request (ust_command) and synchronized
099e26bd
DG
106 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
107 */
108struct ust_cmd_queue {
109 int32_t futex;
8bdee6e2
SM
110 struct cds_wfcq_head head;
111 struct cds_wfcq_tail tail;
099e26bd
DG
112};
113
f45e313d
DG
114/*
115 * This is the wait queue containing wait nodes during the application
116 * registration process.
117 */
118struct ust_reg_wait_queue {
119 unsigned long count;
120 struct cds_list_head head;
121};
122
123/*
124 * Use by the dispatch registration to queue UST command socket to wait for the
125 * notify socket.
126 */
127struct ust_reg_wait_node {
128 struct ust_app *app;
129 struct cds_list_head head;
130};
131
0b2dc8df
MD
132/*
133 * Used to notify that a hash table needs to be destroyed by dedicated
134 * thread. Required by design because we don't want to move destroy
135 * paths outside of large RCU read-side lock paths, and destroy cannot
136 * be called by call_rcu thread, because it may hang (waiting for
137 * call_rcu completion).
138 */
139extern int ht_cleanup_pipe[2];
140
e32d7f27
JG
141extern int kernel_poll_pipe[2];
142
12744796
DG
143/*
144 * Populated when the daemon starts with the current page size of the system.
a7333da7 145 * Set in main() with the current page size.
12744796
DG
146 */
147extern long page_size;
148
5e97de00
JG
149/* Application health monitoring */
150extern struct health_app *health_sessiond;
151
a7333da7 152extern struct sessiond_config config;
26296c48 153
a7333da7
JG
154extern int ust_consumerd64_fd, ust_consumerd32_fd;
155
156/* Parent PID for --sig-parent option */
157extern pid_t ppid;
158/* Internal parent PID use with daemonize. */
159extern pid_t child_ppid;
e9404c27 160
917a718d
JG
161/* Consumer daemon specific control data. */
162extern struct consumer_data ustconsumer32_data;
163extern struct consumer_data ustconsumer64_data;
164extern struct consumer_data kconsumer_data;
165
a7333da7 166int sessiond_init_thread_quit_pipe(void);
d0b96690 167int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
a7333da7
JG
168int sessiond_wait_for_quit_pipe(unsigned int timeout_us);
169int sessiond_notify_quit_pipe(void);
170void sessiond_close_quit_pipe(void);
171
5e97de00 172int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
9cc1ba3b 173void sessiond_signal_parents(void);
ef367a93 174
99d688f2
JG
175void sessiond_set_client_thread_state(bool running);
176void sessiond_wait_client_thread_stopped(void);
177
917a718d
JG
178void *thread_manage_consumer(void *data);
179
fac6795d 180#endif /* _LTT_SESSIOND_H */
This page took 0.06356 seconds and 4 git commands to generate.