Commit | Line | Data |
---|---|---|
9e32c5c0 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 <pthread.h> | |
7f2a8058 | 21 | #include <urcu.h> |
9e32c5c0 CB |
22 | |
23 | /* | |
24 | * Check if the specified environment variable is set. | |
25 | * Return 1 if set, otherwise 0. | |
26 | */ | |
27 | int check_env_var(const char *env) | |
28 | { | |
29 | if (env) { | |
30 | char *env_val = getenv(env); | |
31 | if (env_val && (strncmp(env_val, "1", 1) == 0)) { | |
32 | return 1; | |
33 | } | |
34 | } | |
35 | ||
36 | return 0; | |
37 | } | |
38 | ||
6993eeb3 | 39 | int __testpoint_thread_manage_clients(void) |
9e32c5c0 CB |
40 | { |
41 | const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_EXIT"; | |
42 | ||
43 | if (check_env_var(var)) { | |
7f2a8058 | 44 | rcu_unregister_thread(); |
9e32c5c0 CB |
45 | pthread_exit(NULL); |
46 | } | |
6993eeb3 CB |
47 | |
48 | return 0; | |
9e32c5c0 CB |
49 | } |
50 | ||
6993eeb3 | 51 | int __testpoint_thread_registration_apps(void) |
9e32c5c0 CB |
52 | { |
53 | const char *var = "LTTNG_THREAD_REG_APPS_EXIT"; | |
54 | ||
55 | if (check_env_var(var)) { | |
56 | pthread_exit(NULL); | |
57 | } | |
6993eeb3 CB |
58 | |
59 | return 0; | |
9e32c5c0 CB |
60 | } |
61 | ||
6993eeb3 | 62 | int __testpoint_thread_manage_apps(void) |
9e32c5c0 CB |
63 | { |
64 | const char *var = "LTTNG_THREAD_MANAGE_APPS_EXIT"; | |
65 | ||
66 | if (check_env_var(var)) { | |
7f2a8058 | 67 | rcu_unregister_thread(); |
9e32c5c0 CB |
68 | pthread_exit(NULL); |
69 | } | |
6993eeb3 CB |
70 | |
71 | return 0; | |
9e32c5c0 CB |
72 | } |
73 | ||
6993eeb3 | 74 | int __testpoint_thread_manage_kernel(void) |
9e32c5c0 CB |
75 | { |
76 | const char *var = "LTTNG_THREAD_MANAGE_KERNEL_EXIT"; | |
77 | ||
78 | if (check_env_var(var)) { | |
79 | pthread_exit(NULL); | |
80 | } | |
6993eeb3 CB |
81 | |
82 | return 0; | |
9e32c5c0 CB |
83 | } |
84 | ||
6993eeb3 | 85 | int __testpoint_thread_manage_consumer(void) |
9e32c5c0 CB |
86 | { |
87 | const char *var = "LTTNG_THREAD_MANAGE_CONSUMER_EXIT"; | |
88 | ||
89 | if (check_env_var(var)) { | |
90 | pthread_exit(NULL); | |
91 | } | |
6993eeb3 CB |
92 | |
93 | return 0; | |
9e32c5c0 | 94 | } |