Commit | Line | Data |
---|---|---|
5862a19a CB |
1 | /* |
2 | * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License, version 2 only, as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
15 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | */ | |
17 | ||
18 | #include <stdlib.h> | |
19 | #include <string.h> | |
20 | #include <stdio.h> | |
21 | #include <unistd.h> | |
22 | ||
23 | #define STALL_TIME 60 | |
24 | ||
25 | /* | |
26 | * Check if the specified environment variable is set. | |
27 | * Return 1 if set, otherwise 0. | |
28 | */ | |
29 | int check_env_var(const char *env) | |
30 | { | |
31 | if (env) { | |
32 | char *env_val = getenv(env); | |
33 | if (env_val && (strncmp(env_val, "1", 1) == 0)) { | |
34 | return 1; | |
35 | } | |
36 | } | |
37 | ||
38 | return 0; | |
39 | } | |
40 | ||
71ddb4ed | 41 | int __testpoint_sessiond_thread_manage_clients_before_loop(void) |
5862a19a | 42 | { |
71ddb4ed | 43 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_CLIENTS_STALL"; |
5862a19a CB |
44 | |
45 | if (check_env_var(var)) { | |
050eba6d CB |
46 | unsigned int sleep_time = STALL_TIME; |
47 | while (sleep_time > 0) { | |
48 | sleep_time = sleep(sleep_time); | |
49 | } | |
5862a19a | 50 | } |
6993eeb3 CB |
51 | |
52 | return 0; | |
5862a19a CB |
53 | } |
54 | ||
71ddb4ed | 55 | int __testpoint_sessiond_thread_manage_kernel_before_loop(void) |
5862a19a | 56 | { |
71ddb4ed | 57 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_KERNEL_STALL"; |
5862a19a CB |
58 | |
59 | if (check_env_var(var)) { | |
050eba6d CB |
60 | unsigned int sleep_time = STALL_TIME; |
61 | while (sleep_time > 0) { | |
62 | sleep_time = sleep(sleep_time); | |
63 | } | |
5862a19a | 64 | } |
6993eeb3 CB |
65 | |
66 | return 0; | |
5862a19a CB |
67 | } |
68 | ||
71ddb4ed | 69 | int __testpoint_sessiond_thread_manage_apps_before_loop(void) |
5862a19a | 70 | { |
71ddb4ed | 71 | const char *var = "LTTNG_SESSIOND_THREAD_MANAGE_APPS_STALL"; |
5862a19a CB |
72 | |
73 | if (check_env_var(var)) { | |
050eba6d CB |
74 | unsigned int sleep_time = STALL_TIME; |
75 | while (sleep_time > 0) { | |
76 | sleep_time = sleep(sleep_time); | |
77 | } | |
5862a19a | 78 | } |
6993eeb3 CB |
79 | |
80 | return 0; | |
5862a19a | 81 | } |