]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: 51d: make use of the late init registration
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 19:30:05 +0000 (20:30 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 21 Dec 2016 20:30:54 +0000 (21:30 +0100)
This removes some #ifdefs from the main haproxy code path. Function
init_51degrees() now returns ERR_* instead of exit(1) on error, and
this function was made static and is not exported anymore.

include/import/51d.h
src/51d.c
src/haproxy.c

index 2335c3535fe0bc21199b7c833ad7e66ac7bf787e..4bab242d7310b9f86b7c16cf668be7158c98612d 100644 (file)
@@ -3,7 +3,6 @@
 
 #include <51Degrees.h>
 
-int init_51degrees(void);
 void deinit_51degrees(void);
 
 #endif
index a44b40be2544784ae6f1d7c95ccfc4ee3c1f6a5a..3e3133a14e459abe199264bbe054113b3b308a39 100644 (file)
--- a/src/51d.c
+++ b/src/51d.c
@@ -3,6 +3,7 @@
 #include <common/cfgparse.h>
 #include <common/chunk.h>
 #include <common/buffer.h>
+#include <common/errors.h>
 #include <proto/arg.h>
 #include <proto/log.h>
 #include <proto/proto_http.h>
@@ -507,7 +508,10 @@ void _51d_init_http_headers()
 }
 #endif
 
-int init_51degrees(void)
+/*
+ * module init / deinit functions. Returns 0 if OK, or a combination of ERR_*.
+ */
+static int init_51degrees(void)
 {
        int i = 0;
        struct chunk *temp;
@@ -516,7 +520,7 @@ int init_51degrees(void)
        fiftyoneDegreesDataSetInitStatus _51d_dataset_status = DATA_SET_INIT_STATUS_NOT_SET;
 
        if (!global._51degrees.data_file_path)
-               return -1;
+               return 0;
 
        if (!LIST_ISEMPTY(&global._51degrees.property_names)) {
                i = 0;
@@ -582,7 +586,7 @@ int init_51degrees(void)
                        Alert("51Degrees Setup - Error reading 51Degrees data file. %s\n", temp->str);
                else
                        Alert("51Degrees Setup - Error reading 51Degrees data file.\n");
-               exit(1);
+               return ERR_ALERT | ERR_FATAL;
        }
        free(_51d_property_list);
 
@@ -649,4 +653,5 @@ static void __51d_init(void)
        sample_register_convs(&conv_kws);
        cfg_register_keywords(&_51dcfg_kws);
        hap_register_build_opts("Built with 51Degrees support.", 0);
+       hap_register_post_check(init_51degrees);
 }
index 4b317d67c61e0476a36aede6310c290060cf0ac5..d5089da270352531a55b9553eb921816ab2a62f5 100644 (file)
@@ -929,9 +929,6 @@ static void init(int argc, char **argv)
 #if defined(USE_DEVICEATLAS)
        init_deviceatlas();
 #endif
-#ifdef USE_51DEGREES
-       init_51degrees();
-#endif
 
        list_for_each_entry(pcf, &post_check_list, list) {
                err_code |= pcf->fct();