mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-05 19:52:14 +00:00
MINOR: chunks: allocate the trash chunks before parsing the config
get_trash_chunk() is convenient also while parsing the config, better allocate them early just like the global trash.
This commit is contained in:
parent
5f3f15f618
commit
2819e99417
@ -609,6 +609,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
if (global.tune.maxrewrite >= global.tune.bufsize / 2)
|
||||
global.tune.maxrewrite = global.tune.bufsize / 2;
|
||||
chunk_init(&trash, realloc(trash.str, global.tune.bufsize), global.tune.bufsize);
|
||||
alloc_trash_buffers(global.tune.bufsize);
|
||||
}
|
||||
else if (!strcmp(args[0], "tune.maxrewrite")) {
|
||||
if (*(args[1]) == 0) {
|
||||
|
@ -51,12 +51,14 @@ struct chunk *get_trash_chunk(void)
|
||||
return trash_chunk;
|
||||
}
|
||||
|
||||
/* Allocates the trash buffers. Returns 0 in case of failure. */
|
||||
/* (re)allocates the trash buffers. Returns 0 in case of failure. It is
|
||||
* possible to call this function multiple times if the trash size changes.
|
||||
*/
|
||||
int alloc_trash_buffers(int bufsize)
|
||||
{
|
||||
trash_size = bufsize;
|
||||
trash_buf1 = (char *)calloc(1, bufsize);
|
||||
trash_buf2 = (char *)calloc(1, bufsize);
|
||||
trash_buf1 = (char *)realloc(trash_buf1, bufsize);
|
||||
trash_buf2 = (char *)realloc(trash_buf2, bufsize);
|
||||
return trash_buf1 && trash_buf2;
|
||||
}
|
||||
|
||||
|
@ -491,6 +491,7 @@ void init(int argc, char **argv)
|
||||
struct tm curtime;
|
||||
|
||||
chunk_init(&trash, malloc(global.tune.bufsize), global.tune.bufsize);
|
||||
alloc_trash_buffers(global.tune.bufsize);
|
||||
|
||||
/* NB: POSIX does not make it mandatory for gethostname() to NULL-terminate
|
||||
* the string in case of truncation, and at least FreeBSD appears not to do
|
||||
@ -817,7 +818,6 @@ void init(int argc, char **argv)
|
||||
swap_buffer = (char *)calloc(1, global.tune.bufsize);
|
||||
get_http_auth_buff = (char *)calloc(1, global.tune.bufsize);
|
||||
static_table_key = calloc(1, sizeof(*static_table_key) + global.tune.bufsize);
|
||||
alloc_trash_buffers(global.tune.bufsize);
|
||||
|
||||
fdinfo = (struct fdinfo *)calloc(1,
|
||||
sizeof(struct fdinfo) * (global.maxsock));
|
||||
|
Loading…
Reference in New Issue
Block a user