sessiond: use epoll()/poll() instead of select()
[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 {
5461b305
DG
90 unsigned int lttng_msg_size;
91 struct ltt_session *session;
92 struct lttcomm_lttng_msg *llm;
93 struct lttcomm_session_msg *lsm;
730389d9 94 lttng_sock_cred creds;
5461b305
DG
95};
96
099e26bd
DG
97struct ust_command {
98 int sock;
99 struct ust_register_msg reg_msg;
8bdee6e2 100 struct cds_wfcq_node node;
099e26bd
DG
101};
102
103/*
7a44d6f1 104 * Queue used to enqueue UST registration request (ust_command) and synchronized
099e26bd
DG
105 * by a futex with a scheme N wakers / 1 waiters. See futex.c/.h
106 */
107struct ust_cmd_queue {
108 int32_t futex;
8bdee6e2
SM
109 struct cds_wfcq_head head;
110 struct cds_wfcq_tail tail;
099e26bd
DG
111};
112
f45e313d
DG
113/*
114 * This is the wait queue containing wait nodes during the application
115 * registration process.
116 */
117struct ust_reg_wait_queue {
118 unsigned long count;
119 struct cds_list_head head;
120};
121
122/*
123 * Use by the dispatch registration to queue UST command socket to wait for the
124 * notify socket.
125 */
126struct ust_reg_wait_node {
127 struct ust_app *app;
128 struct cds_list_head head;
129};
130
0b2dc8df
MD
131/*
132 * Used to notify that a hash table needs to be destroyed by dedicated
133 * thread. Required by design because we don't want to move destroy
134 * paths outside of large RCU read-side lock paths, and destroy cannot
135 * be called by call_rcu thread, because it may hang (waiting for
136 * call_rcu completion).
137 */
138extern int ht_cleanup_pipe[2];
139
e32d7f27
JG
140extern int kernel_poll_pipe[2];
141
12744796
DG
142/*
143 * Populated when the daemon starts with the current page size of the system.
a7333da7 144 * Set in main() with the current page size.
12744796
DG
145 */
146extern long page_size;
147
5e97de00
JG
148/* Application health monitoring */
149extern struct health_app *health_sessiond;
150
a7333da7 151extern struct sessiond_config config;
26296c48 152
a7333da7
JG
153extern int ust_consumerd64_fd, ust_consumerd32_fd;
154
155/* Parent PID for --sig-parent option */
156extern pid_t ppid;
157/* Internal parent PID use with daemonize. */
158extern pid_t child_ppid;
e9404c27 159
917a718d
JG
160/* Consumer daemon specific control data. */
161extern struct consumer_data ustconsumer32_data;
162extern struct consumer_data ustconsumer64_data;
163extern struct consumer_data kconsumer_data;
164
a7333da7 165int sessiond_init_thread_quit_pipe(void);
d0b96690 166int sessiond_check_thread_quit_pipe(int fd, uint32_t events);
2d54bfb6 167int sessiond_wait_for_quit_pipe(int timeout_ms);
a7333da7
JG
168int sessiond_notify_quit_pipe(void);
169void sessiond_close_quit_pipe(void);
170
5e97de00 171int sessiond_set_thread_pollset(struct lttng_poll_event *events, size_t size);
9cc1ba3b 172void sessiond_signal_parents(void);
ef367a93 173
99d688f2
JG
174void sessiond_set_client_thread_state(bool running);
175void sessiond_wait_client_thread_stopped(void);
176
917a718d
JG
177void *thread_manage_consumer(void *data);
178
fac6795d 179#endif /* _LTT_SESSIOND_H */
This page took 0.094501 seconds and 4 git commands to generate.