mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-03 02:32:03 +00:00
CLEANUP: dynbuf: move the reserve and limit parsers to dynbuf.c
I just added a new setting to set the number of reserved buffer, to discover we already had one... Let's move the parsing of this keyword (tune.buffers.reserve) and tune.buffers.limit to dynbuf.c where they should be.
This commit is contained in:
parent
c33b857df9
commit
bc236ad133
@ -36,8 +36,7 @@ static const char *common_kw_list[] = {
|
||||
"insecure-fork-wanted", "insecure-setuid-wanted", "nosplice",
|
||||
"nogetaddrinfo", "noreuseport", "quiet", "zero-warning",
|
||||
"tune.runqueue-depth", "tune.maxpollevents", "tune.maxaccept",
|
||||
"tune.recv_enough", "tune.buffers.limit",
|
||||
"tune.buffers.reserve", "tune.bufsize", "tune.maxrewrite",
|
||||
"tune.recv_enough", "tune.bufsize", "tune.maxrewrite",
|
||||
"tune.idletimer", "tune.rcvbuf.client", "tune.rcvbuf.server",
|
||||
"tune.sndbuf.client", "tune.sndbuf.server", "tune.pipesize",
|
||||
"tune.http.cookielen", "tune.http.logurilen", "tune.http.maxhdr",
|
||||
@ -267,36 +266,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
|
||||
}
|
||||
global.tune.recv_enough = atol(args[1]);
|
||||
}
|
||||
else if (strcmp(args[0], "tune.buffers.limit") == 0) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
if (*(args[1]) == 0) {
|
||||
ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
global.tune.buf_limit = atol(args[1]);
|
||||
if (global.tune.buf_limit) {
|
||||
if (global.tune.buf_limit < 3)
|
||||
global.tune.buf_limit = 3;
|
||||
if (global.tune.buf_limit <= global.tune.reserved_bufs)
|
||||
global.tune.buf_limit = global.tune.reserved_bufs + 1;
|
||||
}
|
||||
}
|
||||
else if (strcmp(args[0], "tune.buffers.reserve") == 0) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
if (*(args[1]) == 0) {
|
||||
ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
|
||||
err_code |= ERR_ALERT | ERR_FATAL;
|
||||
goto out;
|
||||
}
|
||||
global.tune.reserved_bufs = atol(args[1]);
|
||||
if (global.tune.reserved_bufs < 2)
|
||||
global.tune.reserved_bufs = 2;
|
||||
if (global.tune.buf_limit && global.tune.buf_limit <= global.tune.reserved_bufs)
|
||||
global.tune.buf_limit = global.tune.reserved_bufs + 1;
|
||||
}
|
||||
else if (strcmp(args[0], "tune.bufsize") == 0) {
|
||||
if (alertif_too_many_args(1, file, linenum, args, &err_code))
|
||||
goto out;
|
||||
|
63
src/dynbuf.c
63
src/dynbuf.c
@ -15,10 +15,12 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/cfgparse.h>
|
||||
#include <haproxy/dynbuf.h>
|
||||
#include <haproxy/global.h>
|
||||
#include <haproxy/list.h>
|
||||
#include <haproxy/pool.h>
|
||||
#include <haproxy/tools.h>
|
||||
|
||||
struct pool_head *pool_head_buffer __read_mostly;
|
||||
|
||||
@ -121,6 +123,67 @@ void __offer_buffers(void *from, unsigned int count)
|
||||
}
|
||||
}
|
||||
|
||||
/* config parser for global "tune.buffers.limit", accepts a number >= 0 */
|
||||
static int cfg_parse_tune_buffers_limit(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
int limit;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
limit = atoi(args[1]);
|
||||
if (limit < 0) {
|
||||
memprintf(err, "'%s' expects a non-negative number but got '%s'.", args[0], args[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
global.tune.buf_limit = limit;
|
||||
if (global.tune.buf_limit) {
|
||||
if (global.tune.buf_limit < 3)
|
||||
global.tune.buf_limit = 3;
|
||||
if (global.tune.buf_limit <= global.tune.reserved_bufs)
|
||||
global.tune.buf_limit = global.tune.reserved_bufs + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config parser for global "tune.buffers.reserve", accepts a number >= 0 */
|
||||
static int cfg_parse_tune_buffers_reserve(char **args, int section_type, struct proxy *curpx,
|
||||
const struct proxy *defpx, const char *file, int line,
|
||||
char **err)
|
||||
{
|
||||
int reserve;
|
||||
|
||||
if (too_many_args(1, args, err, NULL))
|
||||
return -1;
|
||||
|
||||
reserve = atoi(args[1]);
|
||||
if (reserve < 0) {
|
||||
memprintf(err, "'%s' expects a non-negative number but got '%s'.", args[0], args[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
global.tune.reserved_bufs = reserve;
|
||||
if (global.tune.reserved_bufs < 2)
|
||||
global.tune.reserved_bufs = 2;
|
||||
if (global.tune.buf_limit && global.tune.buf_limit <= global.tune.reserved_bufs)
|
||||
global.tune.buf_limit = global.tune.reserved_bufs + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* config keyword parsers */
|
||||
static struct cfg_kw_list cfg_kws = {ILH, {
|
||||
{ CFG_GLOBAL, "tune.buffers.limit", cfg_parse_tune_buffers_limit },
|
||||
{ CFG_GLOBAL, "tune.buffers.reserve", cfg_parse_tune_buffers_reserve },
|
||||
{ 0, NULL, NULL }
|
||||
}};
|
||||
|
||||
INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* c-indent-level: 8
|
||||
|
Loading…
Reference in New Issue
Block a user