]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: logs: Realloc log buffers only after the config is parsed and checked
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Aug 2017 14:54:41 +0000 (16:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 5 Sep 2017 08:32:38 +0000 (10:32 +0200)
During the configuration parsing, log buffers are reallocated when
global.max_syslog_len is updated. This can be done serveral time. So, instead of
doing it serveral time, we do it only once after the configuration parsing.

src/cfgparse.c
src/haproxy.c

index d49156056563318c2ec35a82d03326d4ce9730bf..fc346b99fc0789332e738f337d6fc2ac70207f8a 100644 (file)
@@ -1418,14 +1418,8 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                else
                        logsrv->maxlen = MAX_SYSLOG_LEN;
 
-               if (logsrv->maxlen > global.max_syslog_len) {
+               if (logsrv->maxlen > global.max_syslog_len)
                        global.max_syslog_len = logsrv->maxlen;
-                       if (!init_log_buffers()) {
-                               Alert("parsing [%s:%d] : failed to initialize log buffers.\n", file, linenum);
-                               err_code |= ERR_ALERT | ERR_FATAL;
-                               goto out;
-                       }
-               }
 
                /* after the length, a format may be specified */
                if (strcmp(args[arg+2], "format") == 0) {
@@ -6081,14 +6075,8 @@ stats_error_parsing:
                        else
                                logsrv->maxlen = MAX_SYSLOG_LEN;
 
-                       if (logsrv->maxlen > global.max_syslog_len) {
+                       if (logsrv->maxlen > global.max_syslog_len)
                                global.max_syslog_len = logsrv->maxlen;
-                               if (!init_log_buffers()) {
-                                       Alert("parsing [%s:%d] : failed to initialize log buffers.\n", file, linenum);
-                                       err_code |= ERR_ALERT | ERR_FATAL;
-                                       goto out;
-                               }
-                       }
 
                        /* after the length, a format may be specified */
                        if (strcmp(args[arg+2], "format") == 0) {
index 7c925eaea7a27fb74e91826d818d1b13027e8df6..47ef859b9f7e0ceead3a1977fa0e0f04fdfbcf80 100644 (file)
@@ -1718,6 +1718,11 @@ static void init(int argc, char **argv)
                exit(1);
        }
 
+       if (!init_log_buffers()) {
+               Alert("failed to initialize log buffers.\n");
+               exit(1);
+       }
+
        swap_buffer = calloc(1, global.tune.bufsize);
        get_http_auth_buff = calloc(1, global.tune.bufsize);
        static_table_key = calloc(1, sizeof(*static_table_key));