From: Willy Tarreau Date: Wed, 21 Dec 2016 19:30:05 +0000 (+0100) Subject: CLEANUP: 51d: make use of the late init registration X-Git-Tag: v1.8-dev1~231 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f3f2549fb023215ba1e0582ed97a9f373d13721;p=thirdparty%2Fhaproxy.git CLEANUP: 51d: make use of the late init registration 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. --- diff --git a/include/import/51d.h b/include/import/51d.h index 2335c3535f..4bab242d73 100644 --- a/include/import/51d.h +++ b/include/import/51d.h @@ -3,7 +3,6 @@ #include <51Degrees.h> -int init_51degrees(void); void deinit_51degrees(void); #endif diff --git a/src/51d.c b/src/51d.c index a44b40be25..3e3133a14e 100644 --- a/src/51d.c +++ b/src/51d.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -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); } diff --git a/src/haproxy.c b/src/haproxy.c index 4b317d67c6..d5089da270 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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();