]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] config: only allocate check buffer when checks are enabled
authorCyril Bonté <cyril.bonte@free.fr>
Wed, 17 Mar 2010 17:56:31 +0000 (18:56 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 17 Mar 2010 21:05:23 +0000 (22:05 +0100)
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]

src/cfgparse.c

index 680b546834e4e0dd16dafb5353a0bc2f721326aa..0e414d0bd5edef61ad14023dc8da39ec47fa0fa2 100644 (file)
@@ -3116,12 +3116,6 @@ stats_error_parsing:
                        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 @@ stats_error_parsing:
                                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;
                }