From: Willy Tarreau Date: Mon, 28 Apr 2014 20:27:06 +0000 (+0200) Subject: MINOR: config: add minimum support for emitting warnings only once X-Git-Tag: v1.5-dev25~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff05550b5df9698610f034e822f08e3b62ba2bb3;p=thirdparty%2Fhaproxy.git MINOR: config: add minimum support for emitting warnings only once This is useful to explain to users what to do during a migration. --- diff --git a/include/types/global.h b/include/types/global.h index 0d9903dad4..21433e86c3 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -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 */ diff --git a/src/haproxy.c b/src/haproxy.c index 9e0f33fd7f..81eaeba8b7 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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 ***************************************/ /*********************************************************************/