mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-24 03:13:06 -04:00
MINOR/OPTIM: http_htx: lookup once http_errors section on check/init
The previous patch has splitted the original proxy_check_errors() function in two, so that check and init steps are performed separately. However, this renders the code inefficient for "errorfiles" directive as tree lookup on http-errors section is performed twice. Optimize this by adding a reference to the section in conf_errors structure. This is resolved during proxy_check_http_errors() and proxy_finalize_http_errors() can reuse it. No need to backport.
This commit is contained in:
parent
d250b381dc
commit
2ca7601c2d
1 changed files with 6 additions and 11 deletions
|
|
@ -49,6 +49,7 @@ struct conf_errors {
|
|||
} inl; /* for HTTP_ERR_DIRECTIVE_INLINE only */
|
||||
struct {
|
||||
char *name; /* the http-errors section name */
|
||||
struct http_errors *resolved; /* resolved section pointer set via proxy_check_http_errors() */
|
||||
enum http_err_import status[HTTP_ERR_SIZE]; /* list of status to import */
|
||||
} section; /* for HTTP_ERR_DIRECTIVE_SECTION only */
|
||||
} type;
|
||||
|
|
@ -2269,7 +2270,6 @@ static int proxy_finalize_http_errors(struct proxy *px)
|
|||
{
|
||||
struct conf_errors *conf_err, *conf_err_back;
|
||||
struct http_errors *http_errs;
|
||||
int section_found;
|
||||
int rc;
|
||||
|
||||
list_for_each_entry_safe(conf_err, conf_err_back, &px->conf.errors, list) {
|
||||
|
|
@ -2284,16 +2284,8 @@ static int proxy_finalize_http_errors(struct proxy *px)
|
|||
break;
|
||||
|
||||
case HTTP_ERR_DIRECTIVE_SECTION:
|
||||
section_found = 0;
|
||||
list_for_each_entry(http_errs, &http_errors_list, list) {
|
||||
if (strcmp(http_errs->id, conf_err->type.section.name) == 0) {
|
||||
section_found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(conf_err->type.section.name);
|
||||
if (section_found) {
|
||||
http_errs = conf_err->type.section.resolved;
|
||||
if (http_errs) {
|
||||
for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
|
||||
if (conf_err->type.section.status[rc] == HTTP_ERR_IMPORT_NO)
|
||||
continue;
|
||||
|
|
@ -2360,6 +2352,7 @@ int proxy_check_http_errors(struct proxy *px)
|
|||
}
|
||||
}
|
||||
|
||||
ha_free(&conf_err->type.section.name);
|
||||
if (!section_found) {
|
||||
ha_alert("proxy '%s': unknown http-errors section '%s' (at %s:%d).\n",
|
||||
px->id, conf_err->type.section.name, conf_err->file, conf_err->line);
|
||||
|
|
@ -2367,6 +2360,8 @@ int proxy_check_http_errors(struct proxy *px)
|
|||
continue;
|
||||
}
|
||||
|
||||
conf_err->type.section.resolved = http_errs;
|
||||
|
||||
for (rc = 0; rc < HTTP_ERR_SIZE; rc++) {
|
||||
if (conf_err->type.section.status[rc] == HTTP_ERR_IMPORT_EXPLICIT &&
|
||||
!http_errs->replies[rc]) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue