[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:
Cyril Bont 2010-03-17 18:56:31 +01:00 committed by Willy Tarreau
parent 039381855d
commit c9f825f060
1 changed files with 7 additions and 6 deletions

View File

@ -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->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;
} else {
newsrv = &curproxy->defsrv;
@ -3563,6 +3557,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
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->state |= SRV_CHECKED;
}