[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]
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 680b546..0e414d0 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -3116,12 +3116,6 @@
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 @@
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;
}