]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] global: add "tune.chksize" to change the default check buffer size
authorWilly Tarreau <w@1wt.eu>
Mon, 4 Oct 2010 18:39:20 +0000 (20:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 30 Oct 2010 17:04:32 +0000 (19:04 +0200)
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)

doc/configuration.txt
include/types/global.h
src/cfgparse.c
src/checks.c
src/haproxy.c

index 9a7c0e37a165ff459a7996fbc52a592aa463a693..04cd5c90eea1986739c5e7921e7aed51e533abd8 100644 (file)
@@ -454,6 +454,7 @@ The following keywords are supported in the "global" section :
    - nosplice
    - spread-checks
    - tune.bufsize
+   - tune.chksize
    - tune.maxaccept
    - tune.maxpollevents
    - tune.maxrewrite
@@ -672,6 +673,13 @@ tune.bufsize <number>
   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,
index fdc1516323a1541a8352b6ccee029c227438690e..4469ef86ba7ef20a31541fc7185ddf7aacaa20f7 100644 (file)
@@ -91,6 +91,7 @@ struct global {
                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 */
index 91d134fa34f745751da24936448ae928e9eed39c..3cf1e4af0d424b66836f5c3b8202920686a6d5c3 100644 (file)
@@ -496,6 +496,14 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                }
                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 @@ stats_error_parsing:
                        }
 
                        /* 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;
index 502d905867cdf0481f631ebb45475a278e2104b8..cd4dd30d9103197063b0f9a637364a2eba36e87a 100644 (file)
@@ -890,8 +890,8 @@ static int event_srv_chk_r(int fd)
         */
 
        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 @@ static int event_srv_chk_r(int fd)
        /* 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';
index 2298ee141c32dab491beabfbb914efc1118e8c14..c8f0a38f176eb25b9e4fe4bd140cc5d16bd2ead5 100644 (file)
@@ -117,6 +117,7 @@ struct global global = {
        .tune = {
                .bufsize = BUFSIZE,
                .maxrewrite = MAXREWRITE,
+               .chksize = BUFSIZE,
        },
        /* others NULL OK */
 };