mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
[OPTIM] config: only allocate check buffer when checks are enabled
To save a little memory, the check_data buffer is only allocated for the servers that are checked. [WT: this patch saves 80 MB of RAM on the test config with 5000 servers]
This commit is contained in:
parent
039381855d
commit
c9f825f060
@ -3116,12 +3116,6 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
newsrv->curfd = -1; /* no health-check in progress */
|
newsrv->curfd = -1; /* no health-check in progress */
|
||||||
newsrv->health = newsrv->rise; /* up, but will fall down at first failure */
|
newsrv->health = newsrv->rise; /* up, but will fall down at first failure */
|
||||||
|
|
||||||
/* Allocate buffer for partial check results... */
|
|
||||||
if ((newsrv->check_data = calloc(BUFSIZE, sizeof(char))) == NULL) {
|
|
||||||
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
|
|
||||||
err_code |= ERR_ALERT | ERR_ABORT;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
cur_arg = 3;
|
cur_arg = 3;
|
||||||
} else {
|
} else {
|
||||||
newsrv = &curproxy->defsrv;
|
newsrv = &curproxy->defsrv;
|
||||||
@ -3563,6 +3557,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate buffer for partial check results... */
|
||||||
|
if ((newsrv->check_data = calloc(BUFSIZE, sizeof(char))) == NULL) {
|
||||||
|
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
|
||||||
|
err_code |= ERR_ALERT | ERR_ABORT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
newsrv->check_status = HCHK_STATUS_INI;
|
newsrv->check_status = HCHK_STATUS_INI;
|
||||||
newsrv->state |= SRV_CHECKED;
|
newsrv->state |= SRV_CHECKED;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user