From: Willy Tarreau Date: Thu, 8 Oct 2020 13:32:21 +0000 (+0200) Subject: MINOR: listener: add a few BUG_ON() statements to detect inconsistencies X-Git-Tag: v2.3-dev6~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95a346073935e8639b41bff8a1f30fc85a1a6598;p=thirdparty%2Fhaproxy.git MINOR: listener: add a few BUG_ON() statements to detect inconsistencies We must not have an fd==-1 when switching to certain states. This will later disappear but for now it helps detecting inconsistencies. --- diff --git a/src/listener.c b/src/listener.c index 6368e37b67..48fdc96bba 100644 --- a/src/listener.c +++ b/src/listener.c @@ -255,14 +255,17 @@ void listener_set_state(struct listener *l, enum li_state st) case LI_ASSIGNED: break; case LI_PAUSED: + BUG_ON(l->rx.fd == -1); _HA_ATOMIC_ADD(&px->li_paused, 1); break; case LI_LISTEN: + BUG_ON(l->rx.fd == -1); _HA_ATOMIC_ADD(&px->li_bound, 1); break; case LI_READY: case LI_FULL: case LI_LIMITED: + BUG_ON(l->rx.fd == -1); _HA_ATOMIC_ADD(&px->li_ready, 1); break; } @@ -280,6 +283,7 @@ void enable_listener(struct listener *listener) { HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock); if (listener->state == LI_LISTEN) { + BUG_ON(listener->rx.fd == -1); if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) && !(proc_mask(listener->rx.settings->bind_proc) & pid_bit)) { /* we don't want to enable this listener and don't