mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: stktable: stktable_init() sets err_msg on error
stktable_init() now sets err_msg when error occurs so that caller is able to precisely report the cause of the failure.
This commit is contained in:
parent
b6a9eca88d
commit
b8c19f877a
@ -46,7 +46,7 @@ void stksess_free(struct stktable *t, struct stksess *ts);
|
||||
int stksess_kill(struct stktable *t, struct stksess *ts, int decrefcount);
|
||||
int stktable_get_key_shard(struct stktable *t, const void *key, size_t len);
|
||||
|
||||
int stktable_init(struct stktable *t);
|
||||
int stktable_init(struct stktable *t, char **err_msg);
|
||||
int stktable_parse_type(char **args, int *idx, unsigned long *type, size_t *key_size, const char *file, int linenum);
|
||||
int parse_stick_table(const char *file, int linenum, char **args,
|
||||
struct stktable *t, char *id, char *nid, struct peers *peers);
|
||||
|
@ -4398,8 +4398,10 @@ int check_config_validity()
|
||||
for (t = stktables_list; t; t = t->next) {
|
||||
if (t->proxy)
|
||||
continue;
|
||||
if (!stktable_init(t)) {
|
||||
ha_alert("Parsing [%s:%d]: failed to initialize '%s' stick-table.\n", t->conf.file, t->conf.line, t->id);
|
||||
err = NULL;
|
||||
if (!stktable_init(t, &err)) {
|
||||
ha_alert("Parsing [%s:%d]: failed to initialize '%s' stick-table: %s.\n", t->conf.file, t->conf.line, t->id, err);
|
||||
ha_free(&err);
|
||||
cfgerr++;
|
||||
}
|
||||
}
|
||||
@ -4412,8 +4414,10 @@ int check_config_validity()
|
||||
if ((curproxy->flags & PR_FL_DISABLED) || !curproxy->table)
|
||||
continue;
|
||||
|
||||
if (!stktable_init(curproxy->table)) {
|
||||
ha_alert("Proxy '%s': failed to initialize stick-table.\n", curproxy->id);
|
||||
err = NULL;
|
||||
if (!stktable_init(curproxy->table, &err)) {
|
||||
ha_alert("Proxy '%s': failed to initialize stick-table: %s.\n", curproxy->id, err);
|
||||
ha_free(&err);
|
||||
cfgerr++;
|
||||
}
|
||||
}
|
||||
|
@ -794,8 +794,13 @@ struct task *process_table_expire(struct task *task, void *context, unsigned int
|
||||
return task;
|
||||
}
|
||||
|
||||
/* Perform minimal stick table intializations, report 0 in case of error, 1 if OK. */
|
||||
int stktable_init(struct stktable *t)
|
||||
/* Perform minimal stick table initialization. In case of error, the
|
||||
* function will return 0 and <err_msg> will contain hints about the
|
||||
* error and it is up to the caller to free it.
|
||||
*
|
||||
* Returns 1 on success
|
||||
*/
|
||||
int stktable_init(struct stktable *t, char **err_msg)
|
||||
{
|
||||
int peers_retval = 0;
|
||||
|
||||
@ -812,7 +817,7 @@ int stktable_init(struct stktable *t)
|
||||
if ( t->expire ) {
|
||||
t->exp_task = task_new_anywhere();
|
||||
if (!t->exp_task)
|
||||
return 0;
|
||||
goto mem_error;
|
||||
t->exp_task->process = process_table_expire;
|
||||
t->exp_task->context = (void *)t;
|
||||
}
|
||||
@ -820,9 +825,14 @@ int stktable_init(struct stktable *t)
|
||||
peers_retval = peers_register_table(t->peers.p, t);
|
||||
}
|
||||
|
||||
return (t->pool != NULL) && !peers_retval;
|
||||
if (t->pool == NULL || peers_retval)
|
||||
goto mem_error;
|
||||
}
|
||||
return 1;
|
||||
|
||||
mem_error:
|
||||
memprintf(err_msg, "memory allocation error");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user