]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: global: define tainted flag
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 5 May 2021 14:18:45 +0000 (16:18 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 7 May 2021 12:12:27 +0000 (14:12 +0200)
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
src/haproxy.c

index d3f2e7ee29597d06089fe8cd62f6a84e820100b5..20a0950ea25e2823a0f47dad8aa5a73a3ec03659 100644 (file)
@@ -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)
index ef4a40ca6bf0b2fb137cade2b085cb223fc61d38..4c7ff556eab5b98ce7efd210f2e12b32ad35e97b 100644 (file)
@@ -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