From 484454d906adc747f178e7c5e8c09c2834f6162c Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Wed, 5 May 2021 16:18:45 +0200 Subject: [PATCH] MINOR: global: define tainted flag Add a global flag named 'tainted'. Its purpose is to report various status about experimental features used for the current process lifetime. By default it is initialized to 0. It can be set/retrieve by a couple of new functions mark_tainted()/get_tainted(). Once a flag is set, it cannot be resetted. Currently, no tainted status is implemented, it will be the subject of the following commits. --- include/haproxy/global.h | 7 +++++++ src/haproxy.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/haproxy/global.h b/include/haproxy/global.h index d3f2e7ee2..20a0950ea 100644 --- a/include/haproxy/global.h +++ b/include/haproxy/global.h @@ -96,6 +96,13 @@ static inline unsigned long thread_mask(unsigned long mask) return mask ? mask : all_threads_mask; } +/* handle 'tainted' status */ +enum tainted_flags { + TAINTED_UNIMPLEMENTED, // TO REMOVE once an enum value is implemented +}; +void mark_tainted(const enum tainted_flags flag); +unsigned int get_tainted(); + /* simplified way to declare static build options in a file */ #define REGISTER_BUILD_OPTS(str) \ INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0) diff --git a/src/haproxy.c b/src/haproxy.c index ef4a40ca6..4c7ff556e 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -259,6 +259,9 @@ static void *run_thread_poll_loop(void *data); /* bitfield of a few warnings to emit just once (WARN_*) */ unsigned int warned = 0; +/* set if experimental features have been used for the current process */ +static unsigned int tainted = 0; + /* master CLI configuration (-S flag) */ struct list mworker_cli_conf = LIST_HEAD_INIT(mworker_cli_conf); @@ -1417,6 +1420,17 @@ static int check_if_maxsock_permitted(int maxsock) return ret == 0; } +void mark_tainted(const enum tainted_flags flag) +{ + HA_ATOMIC_OR(&tainted, flag); +} + +unsigned int get_tainted() +{ + int tainted_state; + HA_ATOMIC_STORE(&tainted_state, tainted); + return tainted_state; +} /* * This function initializes all the necessary variables. It only returns