From c2adf8b9062dade3a7d92d9edce19515f59fb1f0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 7 Sep 2011 12:13:34 +0200 Subject: [PATCH] [MEDIUM] stats: disable complex socket reservation for stats socket 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 | 19 ++++++++++++------- src/haproxy.c | 1 - 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/dumpstats.c b/src/dumpstats.c index 746709b80..feeb85091 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -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"); diff --git a/src/haproxy.c b/src/haproxy.c index 97d2e7136..d72a2f119 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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,