Commit | Line | Data |
---|---|---|
5862a19a | 1 | /* |
9d16b343 MJ |
2 | * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com> |
3 | * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
5862a19a | 4 | * |
9d16b343 | 5 | * SPDX-License-Identifier: GPL-2.0-only |
5862a19a | 6 | * |
5862a19a CB |
7 | */ |
8 | ||
4bd69c5f | 9 | #include <lttng/lttng-export.h> |
5862a19a CB |
10 | #include <stdlib.h> |
11 | #include <string.h> | |
a33d2d4a | 12 | #include <pthread.h> |
5862a19a | 13 | #include <unistd.h> |
a33d2d4a | 14 | #include <urcu.h> |
5862a19a CB |
15 | |
16 | #define STALL_TIME 60 | |
17 | ||
18 | /* | |
19 | * Check if the specified environment variable is set. | |
20 | * Return 1 if set, otherwise 0. | |
21 | */ | |
a33d2d4a | 22 | static |
5862a19a CB |
23 | int check_env_var(const char *env) |
24 | { | |
25 | if (env) { | |
26 | char *env_val = getenv(env); | |
27 | if (env_val && (strncmp(env_val, "1", 1) == 0)) { | |
28 | return 1; | |
29 | } | |
30 | } | |
31 | ||
32 | return 0; | |
33 | } | |
34 | ||
a33d2d4a MD |
35 | static |
36 | void do_stall(void) | |
37 | { | |
38 | unsigned int sleep_time = STALL_TIME; | |
39 | ||
40 | while (sleep_time > 0) { | |
41 | sleep_time = sleep(sleep_time); | |
42 | } | |
43 | } | |
44 | ||
45 | /* Session daemon */ | |
46 | ||
4bd69c5f | 47 | LTTNG_EXPORT int __testpoint_sessiond_thread_manage_clients(void); |
a33d2d4a | 48 | int __testpoint_sessiond_thread_manage_clients(void) |
5862a19a | 49 | { |
e547b070 | 50 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL"; |
5862a19a CB |
51 | |
52 | if (check_env_var(var)) { | |
a33d2d4a | 53 | do_stall(); |
5862a19a | 54 | } |
6993eeb3 CB |
55 | |
56 | return 0; | |
5862a19a CB |
57 | } |
58 | ||
4bd69c5f | 59 | LTTNG_EXPORT int __testpoint_sessiond_thread_registration_apps(void); |
a33d2d4a | 60 | int __testpoint_sessiond_thread_registration_apps(void) |
5862a19a | 61 | { |
a33d2d4a | 62 | const char *var = "LTTNG_SESSIOND_THREAD_REG_APPS_STALL"; |
5862a19a CB |
63 | |
64 | if (check_env_var(var)) { | |
a33d2d4a | 65 | do_stall(); |
5862a19a | 66 | } |
6993eeb3 CB |
67 | |
68 | return 0; | |
5862a19a CB |
69 | } |
70 | ||
4bd69c5f | 71 | LTTNG_EXPORT int __testpoint_sessiond_thread_manage_apps(void); |
a33d2d4a | 72 | int __testpoint_sessiond_thread_manage_apps(void) |
5862a19a | 73 | { |
e547b070 | 74 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL"; |
5862a19a CB |
75 | |
76 | if (check_env_var(var)) { | |
a33d2d4a MD |
77 | do_stall(); |
78 | } | |
79 | ||
80 | return 0; | |
81 | } | |
82 | ||
4bd69c5f | 83 | LTTNG_EXPORT int __testpoint_sessiond_thread_manage_kernel(void); |
a33d2d4a MD |
84 | int __testpoint_sessiond_thread_manage_kernel(void) |
85 | { | |
86 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL_STALL"; | |
87 | ||
88 | if (check_env_var(var)) { | |
89 | do_stall(); | |
90 | } | |
91 | ||
92 | return 0; | |
93 | } | |
94 | ||
4bd69c5f | 95 | LTTNG_EXPORT int __testpoint_sessiond_thread_manage_consumer(void); |
a33d2d4a MD |
96 | int __testpoint_sessiond_thread_manage_consumer(void) |
97 | { | |
98 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CONSUMER_STALL"; | |
99 | ||
100 | if (check_env_var(var)) { | |
101 | do_stall(); | |
102 | } | |
103 | ||
104 | return 0; | |
105 | } | |
106 | ||
4bd69c5f | 107 | LTTNG_EXPORT int __testpoint_sessiond_thread_app_manage_notify(void); |
a33d2d4a MD |
108 | int __testpoint_sessiond_thread_app_manage_notify(void) |
109 | { | |
110 | const char *var = "LTTNG_SESSIOND_THREAD_APP_MANAGE_NOTIFY_STALL"; | |
111 | ||
112 | if (check_env_var(var)) { | |
113 | do_stall(); | |
114 | } | |
115 | ||
116 | return 0; | |
117 | } | |
118 | ||
4bd69c5f | 119 | LTTNG_EXPORT int __testpoint_sessiond_thread_app_reg_dispatch(void); |
a33d2d4a MD |
120 | int __testpoint_sessiond_thread_app_reg_dispatch(void) |
121 | { | |
122 | const char *var = "LTTNG_SESSIOND_THREAD_APP_REG_DISPATCH_STALL"; | |
123 | ||
124 | if (check_env_var(var)) { | |
125 | do_stall(); | |
126 | } | |
127 | ||
128 | return 0; | |
129 | } | |
130 | ||
131 | /* Consumer daemon */ | |
132 | ||
4bd69c5f | 133 | LTTNG_EXPORT int __testpoint_consumerd_thread_channel(void); |
a33d2d4a MD |
134 | int __testpoint_consumerd_thread_channel(void) |
135 | { | |
136 | const char *var = "LTTNG_CONSUMERD_THREAD_CHANNEL_STALL"; | |
137 | ||
138 | if (check_env_var(var)) { | |
139 | do_stall(); | |
140 | } | |
141 | ||
142 | return 0; | |
143 | } | |
144 | ||
4bd69c5f | 145 | LTTNG_EXPORT int __testpoint_consumerd_thread_metadata(void); |
a33d2d4a MD |
146 | int __testpoint_consumerd_thread_metadata(void) |
147 | { | |
148 | const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_STALL"; | |
149 | ||
150 | if (check_env_var(var)) { | |
151 | do_stall(); | |
152 | } | |
153 | ||
154 | return 0; | |
155 | } | |
156 | ||
4bd69c5f | 157 | LTTNG_EXPORT int __testpoint_consumerd_thread_data(void); |
a33d2d4a MD |
158 | int __testpoint_consumerd_thread_data(void) |
159 | { | |
160 | const char *var = "LTTNG_CONSUMERD_THREAD_DATA_STALL"; | |
161 | ||
162 | if (check_env_var(var)) { | |
163 | do_stall(); | |
164 | } | |
165 | ||
166 | return 0; | |
167 | } | |
168 | ||
4bd69c5f | 169 | LTTNG_EXPORT int __testpoint_consumerd_thread_sessiond(void); |
a33d2d4a MD |
170 | int __testpoint_consumerd_thread_sessiond(void) |
171 | { | |
172 | const char *var = "LTTNG_CONSUMERD_THREAD_SESSIOND_STALL"; | |
173 | ||
174 | if (check_env_var(var)) { | |
175 | do_stall(); | |
176 | } | |
177 | ||
178 | return 0; | |
179 | } | |
180 | ||
4bd69c5f | 181 | LTTNG_EXPORT int __testpoint_consumerd_thread_metadata_timer(void); |
a33d2d4a MD |
182 | int __testpoint_consumerd_thread_metadata_timer(void) |
183 | { | |
184 | const char *var = "LTTNG_CONSUMERD_THREAD_METADATA_TIMER_STALL"; | |
185 | ||
186 | if (check_env_var(var)) { | |
187 | do_stall(); | |
188 | } | |
189 | ||
190 | return 0; | |
191 | } | |
192 | ||
193 | /* Relay daemon */ | |
194 | ||
4bd69c5f | 195 | LTTNG_EXPORT int __testpoint_relayd_thread_dispatcher(void); |
a33d2d4a MD |
196 | int __testpoint_relayd_thread_dispatcher(void) |
197 | { | |
198 | const char *var = "LTTNG_RELAYD_THREAD_DISPATCHER_STALL"; | |
199 | ||
200 | if (check_env_var(var)) { | |
201 | do_stall(); | |
202 | } | |
203 | ||
204 | return 0; | |
205 | } | |
206 | ||
4bd69c5f | 207 | LTTNG_EXPORT int __testpoint_relayd_thread_worker(void); |
a33d2d4a MD |
208 | int __testpoint_relayd_thread_worker(void) |
209 | { | |
210 | const char *var = "LTTNG_RELAYD_THREAD_WORKER_STALL"; | |
211 | ||
212 | if (check_env_var(var)) { | |
213 | do_stall(); | |
214 | } | |
215 | ||
216 | return 0; | |
217 | } | |
218 | ||
4bd69c5f | 219 | LTTNG_EXPORT int __testpoint_relayd_thread_listener(void); |
a33d2d4a MD |
220 | int __testpoint_relayd_thread_listener(void) |
221 | { | |
222 | const char *var = "LTTNG_RELAYD_THREAD_LISTENER_STALL"; | |
223 | ||
224 | if (check_env_var(var)) { | |
225 | do_stall(); | |
226 | } | |
227 | ||
228 | return 0; | |
229 | } | |
230 | ||
4bd69c5f | 231 | LTTNG_EXPORT int __testpoint_relayd_thread_live_dispatcher(void); |
a33d2d4a MD |
232 | int __testpoint_relayd_thread_live_dispatcher(void) |
233 | { | |
234 | const char *var = "LTTNG_RELAYD_THREAD_LIVE_DISPATCHER_STALL"; | |
235 | ||
236 | if (check_env_var(var)) { | |
237 | do_stall(); | |
238 | } | |
239 | ||
240 | return 0; | |
241 | } | |
242 | ||
4bd69c5f | 243 | LTTNG_EXPORT int __testpoint_relayd_thread_live_worker(void); |
a33d2d4a MD |
244 | int __testpoint_relayd_thread_live_worker(void) |
245 | { | |
246 | const char *var = "LTTNG_RELAYD_THREAD_LIVE_WORKER_STALL"; | |
247 | ||
248 | if (check_env_var(var)) { | |
249 | do_stall(); | |
250 | } | |
251 | ||
252 | return 0; | |
253 | } | |
254 | ||
4bd69c5f | 255 | LTTNG_EXPORT int __testpoint_relayd_thread_live_listener(void); |
a33d2d4a MD |
256 | int __testpoint_relayd_thread_live_listener(void) |
257 | { | |
258 | const char *var = "LTTNG_RELAYD_THREAD_LIVE_LISTENER_STALL"; | |
259 | ||
260 | if (check_env_var(var)) { | |
261 | do_stall(); | |
5862a19a | 262 | } |
6993eeb3 CB |
263 | |
264 | return 0; | |
5862a19a | 265 | } |