]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: filters: use the function registration to initialize all proxies
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 19:13:11 +0000 (20:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 20:30:54 +0000 (21:30 +0100)
Function flt_init() was called in the main init code path, now we move
it to the list of initializers and we can unexport flt_init().

include/proto/filters.h
src/filters.c
src/haproxy.c

index 0cec1dc635cc4337aa9aadba925dac830d17c759..0d3e9acaaada1b175377bb6428615129b51289e3 100644 (file)
@@ -95,7 +95,6 @@
 
 extern struct pool_head *pool2_filter;
 
-int  flt_init(struct proxy *p);
 void flt_deinit(struct proxy *p);
 int  flt_check(struct proxy *p);
 
index 91404a48488ea451de3deb64fb134f5fa7939cf1..14ea0f1f380f05007e4a6a8efab57ea2a33c4c11 100644 (file)
@@ -251,7 +251,7 @@ parse_filter(char **args, int section_type, struct proxy *curpx,
  * the configuration parsing. Filters can finish to fill their config. Returns
  * (ERR_ALERT|ERR_FATAL) if an error occurs, 0 otherwise.
  */
-int
+static int
 flt_init(struct proxy *proxy)
 {
        struct flt_conf *fconf;
@@ -263,6 +263,24 @@ flt_init(struct proxy *proxy)
        return 0;
 }
 
+/* Calls flt_init() for all proxies, see above */
+static int
+flt_init_all()
+{
+       struct proxy *px;
+       int err_code = 0;
+
+       for (px = proxy; px; px = px->next) {
+               err_code |= flt_init(px);
+               if (err_code & (ERR_ABORT|ERR_FATAL)) {
+                       Alert("Failed to initialize filters for proxy '%s'.\n",
+                             px->id);
+                       return err_code;
+               }
+       }
+       return 0;
+}
+
 /*
  * Calls 'check' callback for all filters attached to a proxy. This happens
  * after the configuration parsing but before filters initialization. Returns
@@ -1078,6 +1096,7 @@ __filters_init(void)
 {
         pool2_filter = create_pool("filter", sizeof(struct filter), MEM_F_SHARED);
        cfg_register_keywords(&cfg_kws);
+       hap_register_post_check(flt_init_all);
 }
 
 __attribute__((destructor))
index 5d43cf388069cf886dd3f3ebf79ac95c8d1ba18d..23373415475e5bd49c1838d18c2dae192fc0345b 100644 (file)
@@ -936,15 +936,6 @@ static void init(int argc, char **argv)
        ha_wurfl_init();
 #endif
 
-       for (px = proxy; px; px = px->next) {
-               err_code |= flt_init(px);
-               if (err_code & (ERR_ABORT|ERR_FATAL)) {
-                       Alert("Failed to initialize filters for proxy '%s'.\n",
-                             px->id);
-                       exit(1);
-               }
-       }
-
        list_for_each_entry(pcf, &post_check_list, list) {
                err_code |= pcf->fct();
                if (err_code & (ERR_ABORT|ERR_FATAL))