]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: listener: move bind_conf_alloc() and listener_state_str() to listener.c
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 07:05:08 +0000 (09:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 23:36:51 +0000 (01:36 +0200)
These functions have no reason for being inlined, and they require some
includes with long dependencies. Let's move them to listener.c and trim
unused includes in listener.h.

include/haproxy/listener.h
src/listener.c

index 2212ca9271a79688b924eea10936ea2234db8e82..5bd60c0247b2b973c7a01110cc9094bb44b92280 100644 (file)
 #include <string.h>
 
 #include <haproxy/api.h>
-#include <haproxy/cli-t.h>
-#include <haproxy/list.h>
 #include <haproxy/listener-t.h>
 
+struct proxy;
+struct task;
+
 /* adjust the listener's state and its proxy's listener counters if needed */
 void listener_set_state(struct listener *l, enum li_state st);
 
@@ -171,65 +172,9 @@ const char *bind_find_best_kw(const char *word);
 
 void bind_recount_thread_bits(struct bind_conf *conf);
 unsigned int bind_map_thread_id(const struct bind_conf *conf, unsigned int r);
-
-/* allocate an bind_conf struct for a bind line, and chain it to the frontend <fe>.
- * If <arg> is not NULL, it is duplicated into ->arg to store useful config
- * information for error reporting. NULL is returned on error.
- */
-static inline struct bind_conf *bind_conf_alloc(struct proxy *fe, const char *file,
-                                 int line, const char *arg, struct xprt_ops *xprt)
-{
-       struct bind_conf *bind_conf = calloc(1, sizeof(*bind_conf));
-
-       if (!bind_conf)
-               goto err;
-
-       bind_conf->file = strdup(file);
-       if (!bind_conf->file)
-               goto err;
-       bind_conf->line = line;
-       if (arg) {
-               bind_conf->arg = strdup(arg);
-               if (!bind_conf->arg)
-                       goto err;
-       }
-
-       LIST_APPEND(&fe->conf.bind, &bind_conf->by_fe);
-       bind_conf->settings.ux.uid = -1;
-       bind_conf->settings.ux.gid = -1;
-       bind_conf->settings.ux.mode = 0;
-       bind_conf->xprt = xprt;
-       bind_conf->frontend = fe;
-       bind_conf->severity_output = CLI_SEVERITY_NONE;
-#ifdef USE_OPENSSL
-       HA_RWLOCK_INIT(&bind_conf->sni_lock);
-       bind_conf->sni_ctx = EB_ROOT;
-       bind_conf->sni_w_ctx = EB_ROOT;
-#endif
-       LIST_INIT(&bind_conf->listeners);
-       return bind_conf;
-
-  err:
-       if (bind_conf) {
-               ha_free(&bind_conf->file);
-               ha_free(&bind_conf->arg);
-       }
-       ha_free(&bind_conf);
-       return NULL;
-}
-
-static inline const char *listener_state_str(const struct listener *l)
-{
-       static const char *states[8] = {
-               "NEW", "INI", "ASS", "PAU", "LIS", "RDY", "FUL", "LIM",
-       };
-       unsigned int st = l->state;
-
-       if (st >= sizeof(states) / sizeof(*states))
-               return "INVALID";
-       return states[st];
-}
-
+struct bind_conf *bind_conf_alloc(struct proxy *fe, const char *file,
+                                  int line, const char *arg, struct xprt_ops *xprt);
+const char *listener_state_str(const struct listener *l);
 struct task *accept_queue_process(struct task *t, void *context, unsigned int state);
 struct task *manage_global_listener_queue(struct task *t, void *context, unsigned int state);
 
index 797e866b801b839b4797ee96726284660972577e..be467ea5d832bee1a7493dbafadebeb8697bd916 100644 (file)
@@ -21,6 +21,7 @@
 #include <haproxy/api.h>
 #include <haproxy/activity.h>
 #include <haproxy/cfgparse.h>
+#include <haproxy/cli-t.h>
 #include <haproxy/connection.h>
 #include <haproxy/errors.h>
 #include <haproxy/fd.h>
@@ -1284,6 +1285,64 @@ const char *bind_find_best_kw(const char *word)
        return best_ptr;
 }
 
+/* allocate an bind_conf struct for a bind line, and chain it to the frontend <fe>.
+ * If <arg> is not NULL, it is duplicated into ->arg to store useful config
+ * information for error reporting. NULL is returned on error.
+ */
+struct bind_conf *bind_conf_alloc(struct proxy *fe, const char *file,
+                                  int line, const char *arg, struct xprt_ops *xprt)
+{
+       struct bind_conf *bind_conf = calloc(1, sizeof(*bind_conf));
+
+       if (!bind_conf)
+               goto err;
+
+       bind_conf->file = strdup(file);
+       if (!bind_conf->file)
+               goto err;
+       bind_conf->line = line;
+       if (arg) {
+               bind_conf->arg = strdup(arg);
+               if (!bind_conf->arg)
+                       goto err;
+       }
+
+       LIST_APPEND(&fe->conf.bind, &bind_conf->by_fe);
+       bind_conf->settings.ux.uid = -1;
+       bind_conf->settings.ux.gid = -1;
+       bind_conf->settings.ux.mode = 0;
+       bind_conf->xprt = xprt;
+       bind_conf->frontend = fe;
+       bind_conf->severity_output = CLI_SEVERITY_NONE;
+#ifdef USE_OPENSSL
+       HA_RWLOCK_INIT(&bind_conf->sni_lock);
+       bind_conf->sni_ctx = EB_ROOT;
+       bind_conf->sni_w_ctx = EB_ROOT;
+#endif
+       LIST_INIT(&bind_conf->listeners);
+       return bind_conf;
+
+  err:
+       if (bind_conf) {
+               ha_free(&bind_conf->file);
+               ha_free(&bind_conf->arg);
+       }
+       ha_free(&bind_conf);
+       return NULL;
+}
+
+const char *listener_state_str(const struct listener *l)
+{
+       static const char *states[8] = {
+               "NEW", "INI", "ASS", "PAU", "LIS", "RDY", "FUL", "LIM",
+       };
+       unsigned int st = l->state;
+
+       if (st >= sizeof(states) / sizeof(*states))
+               return "INVALID";
+       return states[st];
+}
+
 /************************************************************************/
 /*      All supported sample and ACL keywords must be declared here.    */
 /************************************************************************/