]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: cfgparse: load_cfg_in_mem: take in account file size
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 7 Aug 2024 14:31:25 +0000 (16:31 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Aug 2024 16:41:41 +0000 (18:41 +0200)
commit03e63b98ca1bb9c3b706eac01529c3834917a10f
tree3efcad14c2d3d7f696be6051f7f83c8f0f187ce2
parent5b9ed6e4bede716dfcf53d1d488dc15701bceac8
MINOR: cfgparse: load_cfg_in_mem: take in account file size

Let's take in account the given file size, when its reported via stat.

It's very convenient for large configuration files, as this allows to
perform only the one memory allocation call for precisely needeed file size.
This also allows to perform only the one call to fread().

We need to provide to fread() file_stat.st_size + 1 to be able to grab EOF.
Like this it sets feof(f)=1 flag and this allows to exit from the loop
immediately, just after fread call.

If /dev/stdin or /dev/null is provided as a file, we continue to read the
configuration chunk by chunk, stat doesn't report the size.
src/cfgparse.c