]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: add a function to return a listener's state as a string
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Jul 2017 17:46:06 +0000 (19:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Jul 2017 15:03:12 +0000 (17:03 +0200)
This will be used in debugging output, so it's a short 3-character string.

include/proto/listener.h

index 079d976a30716e6317d83fad0c1de32c95b49aab..770f266d1ce5523269d9cadcf152fa4d7db1eceb 100644 (file)
@@ -149,6 +149,18 @@ static inline struct bind_conf *bind_conf_alloc(struct proxy *fe, const char *fi
        return bind_conf;
 }
 
+static inline const char *listener_state_str(const struct listener *l)
+{
+       static const char *states[9] = {
+               "NEW", "INI", "ASS", "PAU", "ZOM", "LIS", "RDY", "FUL", "LIM",
+       };
+       unsigned int st = l->state;
+
+       if (st > sizeof(states) / sizeof(*states))
+               return "INVALID";
+       return states[st];
+}
+
 extern struct xfer_sock_list *xfer_sock_list;
 #endif /* _PROTO_LISTENER_H */