]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: add a few BUG_ON() statements to detect inconsistencies
authorWilly Tarreau <w@1wt.eu>
Thu, 8 Oct 2020 13:32:21 +0000 (15:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Oct 2020 16:29:04 +0000 (18:29 +0200)
We must not have an fd==-1 when switching to certain states. This will
later disappear but for now it helps detecting inconsistencies.

src/listener.c

index 6368e37b67e4aa0b3b831a390bdac57889024a26..48fdc96bbadf7dd84a93edf989c531000d5f66e6 100644 (file)
@@ -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