[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)
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 9a7c0e3..04cd5c9 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -454,6 +454,7 @@
- nosplice
- spread-checks
- tune.bufsize
+ - tune.chksize
- tune.maxaccept
- tune.maxpollevents
- tune.maxrewrite
@@ -672,6 +673,13 @@
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.
+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>
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,
diff --git a/include/types/global.h b/include/types/global.h
index fdc1516..4469ef8 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -91,6 +91,7 @@
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_rcvbuf; /* set server rcvbuf to this value if not null */
+ int chksize; /* check buffer size in bytes, defaults to BUFSIZE */
} tune;
struct listener stats_sock; /* unix socket listener for statistics */
struct proxy *stats_fe; /* the frontend holding the stats settings */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 91d134f..3cf1e4a 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -496,6 +496,14 @@
}
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")) {
if (*(args[1]) == 0) {
Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
@@ -3786,7 +3794,7 @@
}
/* 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);
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
diff --git a/src/checks.c b/src/checks.c
index 502d905..cd4dd30 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -890,8 +890,8 @@
*/
done = 0;
- for (len = 0; s->check_data_len < BUFSIZE; s->check_data_len += len) {
- len = recv(fd, s->check_data + s->check_data_len, BUFSIZE - s->check_data_len, 0);
+ 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, global.tune.chksize - s->check_data_len, 0);
if (len <= 0)
break;
}
@@ -915,7 +915,7 @@
/* Intermediate or complete response received.
* 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';
else {
s->check_data[s->check_data_len - 1] = '\0';
diff --git a/src/haproxy.c b/src/haproxy.c
index 2298ee1..c8f0a38 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -117,6 +117,7 @@
.tune = {
.bufsize = BUFSIZE,
.maxrewrite = MAXREWRITE,
+ .chksize = BUFSIZE,
},
/* others NULL OK */
};