[MINOR] global: add "tune.chksize" to change the default check buffer size

HTTP content-based health checks will be involved in searching text in pages.
Some pages may not fit in the default buffer (16kB) and sometimes it might be
desired to have larger buffers in order to find patterns. Running checks on
smaller URIs is always preferred of course.
(cherry picked from commit 043f44aeb835f3d0b57626c4276581a73600b6b1)
This commit is contained in:
Willy Tarreau 2010-10-04 20:39:20 +02:00
parent a246e9ec8a
commit 43961d523f
5 changed files with 22 additions and 4 deletions

View File

@ -454,6 +454,7 @@ The following keywords are supported in the "global" section :
- nosplice - nosplice
- spread-checks - spread-checks
- tune.bufsize - tune.bufsize
- tune.chksize
- tune.maxaccept - tune.maxaccept
- tune.maxpollevents - tune.maxpollevents
- tune.maxrewrite - tune.maxrewrite
@ -672,6 +673,13 @@ tune.bufsize <number>
possibly causing the system to run out of memory. At least the global maxconn possibly causing the system to run out of memory. At least the global maxconn
parameter should be decreased by the same factor as this one is increased. parameter should be decreased by the same factor as this one is increased.
tune.chksize <number>
Sets the check buffer size to this size (in bytes). Higher values may help
find string or regex patterns in very large pages, though doing so may imply
more memory and CPU usage. The default value is 16384 and can be changed at
build time. It is not recommended to change this value, but to use better
checks whenever possible.
tune.maxaccept <number> tune.maxaccept <number>
Sets the maximum number of consecutive accepts that a process may perform on Sets the maximum number of consecutive accepts that a process may perform on
a single wake up. High values give higher priority to high connection rates, a single wake up. High values give higher priority to high connection rates,

View File

@ -91,6 +91,7 @@ struct global {
int client_rcvbuf; /* set client rcvbuf to this value if not null */ int client_rcvbuf; /* set client rcvbuf to this value if not null */
int server_sndbuf; /* set server sndbuf to this value if not null */ int server_sndbuf; /* set server sndbuf to this value if not null */
int server_rcvbuf; /* set server rcvbuf to this value if not null */ int server_rcvbuf; /* set server rcvbuf to this value if not null */
int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
} tune; } tune;
struct listener stats_sock; /* unix socket listener for statistics */ struct listener stats_sock; /* unix socket listener for statistics */
struct proxy *stats_fe; /* the frontend holding the stats settings */ struct proxy *stats_fe; /* the frontend holding the stats settings */

View File

@ -496,6 +496,14 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
} }
global.tune.maxaccept = atol(args[1]); global.tune.maxaccept = atol(args[1]);
} }
else if (!strcmp(args[0], "tune.chksize")) {
if (*(args[1]) == 0) {
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
global.tune.chksize = atol(args[1]);
}
else if (!strcmp(args[0], "tune.bufsize")) { else if (!strcmp(args[0], "tune.bufsize")) {
if (*(args[1]) == 0) { if (*(args[1]) == 0) {
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
@ -3786,7 +3794,7 @@ stats_error_parsing:
} }
/* Allocate buffer for partial check results... */ /* Allocate buffer for partial check results... */
if ((newsrv->check_data = calloc(BUFSIZE, sizeof(char))) == NULL) { if ((newsrv->check_data = calloc(global.tune.chksize, sizeof(char))) == NULL) {
Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum); Alert("parsing [%s:%d] : out of memory while allocating check buffer.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT; err_code |= ERR_ALERT | ERR_ABORT;
goto out; goto out;

View File

@ -890,8 +890,8 @@ static int event_srv_chk_r(int fd)
*/ */
done = 0; done = 0;
for (len = 0; s->check_data_len < BUFSIZE; s->check_data_len += len) { for (len = 0; s->check_data_len < global.tune.chksize; s->check_data_len += len) {
len = recv(fd, s->check_data + s->check_data_len, BUFSIZE - s->check_data_len, 0); len = recv(fd, s->check_data + s->check_data_len, global.tune.chksize - s->check_data_len, 0);
if (len <= 0) if (len <= 0)
break; break;
} }
@ -915,7 +915,7 @@ static int event_srv_chk_r(int fd)
/* Intermediate or complete response received. /* Intermediate or complete response received.
* Terminate string in check_data buffer. * Terminate string in check_data buffer.
*/ */
if (s->check_data_len < BUFSIZE) if (s->check_data_len < global.tune.chksize)
s->check_data[s->check_data_len] = '\0'; s->check_data[s->check_data_len] = '\0';
else { else {
s->check_data[s->check_data_len - 1] = '\0'; s->check_data[s->check_data_len - 1] = '\0';

View File

@ -117,6 +117,7 @@ struct global global = {
.tune = { .tune = {
.bufsize = BUFSIZE, .bufsize = BUFSIZE,
.maxrewrite = MAXREWRITE, .maxrewrite = MAXREWRITE,
.chksize = BUFSIZE,
}, },
/* others NULL OK */ /* others NULL OK */
}; };