]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: add minimum support for emitting warnings only once
authorWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2014 20:27:06 +0000 (22:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 28 Apr 2014 22:46:01 +0000 (00:46 +0200)
This is useful to explain to users what to do during a migration.

include/types/global.h
src/haproxy.c

index 0d9903dad48d75879631927ce3cd572f0ed478d8..21433e86c3eb10c5dd9dabff582c9a23da7cfc85 100644 (file)
@@ -170,6 +170,19 @@ extern char hostname[MAX_HOSTNAME_LEN];
 extern char localpeer[MAX_HOSTNAME_LEN];
 extern struct list global_listener_queue; /* list of the temporarily limited listeners */
 extern struct task *global_listener_queue_task;
+extern unsigned int warned;     /* bitfield of a few warnings to emit just once */
+
+/* bit values to go with "warned" above */
+/* #define WARN_* */
+
+/* to be used with warned and WARN_* */
+static inline int already_warned(unsigned int warning)
+{
+       if (warned & warning)
+               return 1;
+       warned |= warning;
+       return 0;
+}
 
 #endif /* _TYPES_GLOBAL_H */
 
index 9e0f33fd7fda4ecf46319e30d99d0db3e7924f28..81eaeba8b78173bfd0fd57cd3bac2b89f8b0db9d 100644 (file)
@@ -205,6 +205,9 @@ struct list global_listener_queue = LIST_HEAD_INIT(global_listener_queue);
 struct task *global_listener_queue_task;
 static struct task *manage_global_listener_queue(struct task *t);
 
+/* bitfield of a few warnings to emit just once (WARN_*) */
+unsigned int warned = 0;
+
 /*********************************************************************/
 /*  general purpose functions  ***************************************/
 /*********************************************************************/