From 6d0d3f65465c3d2693757faf2f7598a8c811dbc3 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 25 Jul 2017 19:46:06 +0200 Subject: [PATCH] MINOR: listener: add a function to return a listener's state as a string This will be used in debugging output, so it's a short 3-character string. --- include/proto/listener.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/proto/listener.h b/include/proto/listener.h index 079d976a30..770f266d1c 100644 --- a/include/proto/listener.h +++ b/include/proto/listener.h @@ -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 */