Fix: zero out data structure before using it
[lttng-tools.git] / tests / regression / tools / health / health_exit.c
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>
21 #include <urcu.h>
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
39 int __testpoint_thread_manage_clients(void)
40 {
41 const char *var = "LTTNG_THREAD_MANAGE_CLIENTS_EXIT";
42
43 if (check_env_var(var)) {
44 rcu_unregister_thread();
45 pthread_exit(NULL);
46 }
47
48 return 0;
49 }
50
51 int __testpoint_thread_registration_apps(void)
52 {
53 const char *var = "LTTNG_THREAD_REG_APPS_EXIT";
54
55 if (check_env_var(var)) {
56 pthread_exit(NULL);
57 }
58
59 return 0;
60 }
61
62 int __testpoint_thread_manage_apps(void)
63 {
64 const char *var = "LTTNG_THREAD_MANAGE_APPS_EXIT";
65
66 if (check_env_var(var)) {
67 rcu_unregister_thread();
68 pthread_exit(NULL);
69 }
70
71 return 0;
72 }
73
74 int __testpoint_thread_manage_kernel(void)
75 {
76 const char *var = "LTTNG_THREAD_MANAGE_KERNEL_EXIT";
77
78 if (check_env_var(var)) {
79 pthread_exit(NULL);
80 }
81
82 return 0;
83 }
84
85 int __testpoint_thread_manage_consumer(void)
86 {
87 const char *var = "LTTNG_THREAD_MANAGE_CONSUMER_EXIT";
88
89 if (check_env_var(var)) {
90 pthread_exit(NULL);
91 }
92
93 return 0;
94 }
This page took 0.031401 seconds and 5 git commands to generate.