mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-24 20:31:00 +01:00
MINOR: 51d: unable to start haproxy without "51degrees-data-file"
This patch adds a few checks on "global._51degrees.data_file_path" and allows haproxy to start even when the pattern or trie data file is not specified. If the "51d" converter is used, a new function "_51d_conv_check" will check "global._51degrees.data_file_path" and displays a warning if necessary. In src/haproxy.c, the global 51Degrees "cache_size" has moved outside of the FIFTYONEDEGREES_H_PATTERN_INCLUDED ifdef block.
This commit is contained in:
parent
067fceffb3
commit
9373fc5811
15
src/51d.c
15
src/51d.c
@ -104,6 +104,16 @@ static int _51d_cache_size(char **args, int section_type, struct proxy *curpx,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _51d_conv_check(struct arg *arg, struct sample_conv *conv,
|
||||||
|
const char *file, int line, char **err)
|
||||||
|
{
|
||||||
|
if (global._51degrees.data_file_path)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
memprintf(err, "51Degrees data file is not specified (parameter '51degrees-data-file')");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
|
static int _51d_conv(const struct arg *args, struct sample *smp, void *private)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -218,6 +228,9 @@ int init_51degrees(void)
|
|||||||
char **_51d_property_list = NULL;
|
char **_51d_property_list = NULL;
|
||||||
fiftyoneDegreesDataSetInitStatus _51d_dataset_status = DATA_SET_INIT_STATUS_NOT_SET;
|
fiftyoneDegreesDataSetInitStatus _51d_dataset_status = DATA_SET_INIT_STATUS_NOT_SET;
|
||||||
|
|
||||||
|
if (!global._51degrees.data_file_path)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!LIST_ISEMPTY(&global._51degrees.property_names)) {
|
if (!LIST_ISEMPTY(&global._51degrees.property_names)) {
|
||||||
i = 0;
|
i = 0;
|
||||||
list_for_each_entry(name, &global._51degrees.property_names, list)
|
list_for_each_entry(name, &global._51degrees.property_names, list)
|
||||||
@ -314,7 +327,7 @@ static struct cfg_kw_list _51dcfg_kws = {{ }, {
|
|||||||
|
|
||||||
/* Note: must not be declared <const> as its list will be overwritten */
|
/* Note: must not be declared <const> as its list will be overwritten */
|
||||||
static struct sample_conv_kw_list conv_kws = {ILH, {
|
static struct sample_conv_kw_list conv_kws = {ILH, {
|
||||||
{ "51d", _51d_conv, ARG5(1,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR },
|
{ "51d", _51d_conv, ARG5(1,STR,STR,STR,STR,STR), _51d_conv_check, SMP_T_STR, SMP_T_STR },
|
||||||
{ NULL, NULL, 0, 0, 0 },
|
{ NULL, NULL, 0, 0, 0 },
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
@ -195,8 +195,8 @@ struct global global = {
|
|||||||
.data_file_path = NULL,
|
.data_file_path = NULL,
|
||||||
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
#ifdef FIFTYONEDEGREES_H_PATTERN_INCLUDED
|
||||||
.data_set = { },
|
.data_set = { },
|
||||||
.cache_size = 0,
|
|
||||||
#endif
|
#endif
|
||||||
|
.cache_size = 0,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
/* others NULL OK */
|
/* others NULL OK */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user