mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-15 11:22:12 +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:
committed by
Willy Tarreau
parent
b6a9eca88d
commit
b8c19f877a
@@ -4398,8 +4398,10 @@ init_proxies_list_stage2:
|
||||
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 @@ init_proxies_list_stage2:
|
||||
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 @@ out_unlock:
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user