]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] stats: disable complex socket reservation for stats socket
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2011 10:13:34 +0000 (12:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Sep 2011 16:05:48 +0000 (18:05 +0200)
The way the unix socket is initialized is awkward. Some of the settings are put
in the sockets itself, other ones in the backend. And more importantly the
global.maxsock value is adjusted so that the stats socket evades the global
maxconn value. This complexifies maxsock computations for nothing, since the
stats socket is not supposed to receive hundreds of concurrent connections when
the global maxconn is very low. What is needed however is to ensure that there
are always connections left for the stats socket even when traffic sockets are
saturated, but this guarantee is not offered anymore by current code.

So as of now, the stats socket is subject to the global maxconn limitation just
as any other socket until a reservation mechanism is implemented.

src/dumpstats.c
src/haproxy.c

index 746709b80c732e861f99361f182972c4aa80b134..feeb8509134e7a84d9d1cb578adeeb05deeb2a64 100644 (file)
@@ -160,6 +160,9 @@ static struct proxy *alloc_stats_fe(const char *name)
        fe->last_change = now.tv_sec;
        fe->id = strdup("GLOBAL");
        fe->cap = PR_CAP_FE;
+       fe->maxconn = 10;                 /* default to 10 concurrent connections */
+       fe->timeout.client = MS_TO_TICKS(10000); /* default timeout of 10 seconds */
+
        return fe;
 }
 
@@ -199,7 +202,6 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
                                snprintf(err, errlen, "out of memory");
                                return -1;
                        }
-                       global.stats_fe->timeout.client = MS_TO_TICKS(10000); /* default timeout of 10 seconds */
                }
 
                global.stats_sock.state = LI_INIT;
@@ -211,7 +213,7 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
                global.stats_sock.nice = -64;  /* we want to boost priority for local stats */
                global.stats_sock.frontend = global.stats_fe;
                global.stats_sock.perm.ux.level = ACCESS_LVL_OPER; /* default access level */
-               global.stats_fe->maxconn = global.stats_sock.maxconn;
+               global.stats_sock.maxconn = global.stats_fe->maxconn;
                global.stats_sock.timeout = &global.stats_fe->timeout.client;
 
                global.stats_sock.next  = global.stats_fe->listen;
@@ -303,11 +305,14 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
                        snprintf(err, errlen, "a positive value is expected for 'stats maxconn' in 'global section'");
                        return -1;
                }
-               global.maxsock -= global.stats_sock.maxconn;
-               global.stats_sock.maxconn = maxconn;
-               global.maxsock += global.stats_sock.maxconn;
-               if (global.stats_fe)
-                       global.stats_fe->maxconn = global.stats_sock.maxconn;
+
+               if (!global.stats_fe) {
+                       if ((global.stats_fe = alloc_stats_fe("GLOBAL")) == NULL) {
+                               snprintf(err, errlen, "out of memory");
+                               return -1;
+                       }
+               }
+               global.stats_fe->maxconn = maxconn;
        }
        else {
                snprintf(err, errlen, "'stats' only supports 'socket', 'maxconn' and 'timeout' in 'global' section");
index 97d2e7136caebf67d2cc0e9505e5239106e1ae0b..d72a2f1191e81e115396e3ec79b87ecbb7f7beac 100644 (file)
@@ -106,7 +106,6 @@ struct global global = {
        loglev1 : 7, /* max syslog level : debug */
        loglev2 : 7,
        .stats_sock = {
-               .maxconn = 10, /* 10 concurrent stats connections */
                .perm = {
                         .ux = {
                                 .uid = -1,