MINOR: listener: move LI_O_UNLIMITED and LI_O_NOSTOP to bind_conf
These two flags are entirely for internal use and are even per proxy
in practice since they're used for peers and CLI to indicate (for the
first one) that the listener(s) are not subject to connection limits,
and for the second that the listener(s) should not be stopped on
soft-stop. No need to keep them in the listeners, let's move them to
the bind_conf under names BC_O_UNLIMITED and BC_O_NOSTOP.
diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h
index 338ab9d..7f0b286 100644
--- a/include/haproxy/listener-t.h
+++ b/include/haproxy/listener-t.h
@@ -100,16 +100,16 @@
#define LI_O_TCP_L5_RULES 0x0020 /* run TCP L5 rules checks on the incoming session */
/* unused 0x0040 */
/* unused 0x0080 */
-#define LI_O_UNLIMITED 0x0100 /* listener not subject to global limits (peers & stats socket) */
+/* unused 0x0100 */
/* unused 0x0200 */
/* unused 0x0400 */
/* unused 0x0800 */
/* unused 0x1000 */
/* unused 0x2000 */
/* unused 0x4000 */
-#define LI_O_NOSTOP 0x8000 /* keep the listener active even after a soft stop */
+/* unused 0x8000 */
-/* Note: if a listener uses LI_O_UNLIMITED, it is highly recommended that it adds its own
+/* Note: if a bind_conf uses BC_O_UNLIMITED, it is highly recommended that it adds its own
* maxconn setting to the global.maxsock value so that its resources are reserved.
*/
@@ -127,6 +127,8 @@
#define BC_O_TCP_FO 0x00000400 /* enable TCP Fast Open (linux >= 3.7) */
#define BC_O_ACC_PROXY 0x00000800 /* find the proxied address in the first request line */
#define BC_O_ACC_CIP 0x00001000 /* find the proxied address in the NetScaler Client IP header */
+#define BC_O_UNLIMITED 0x00002000 /* listeners not subject to global limits (peers & stats socket) */
+#define BC_O_NOSTOP 0x00004000 /* keep the listeners active even after a soft stop */
/* flags used with bind_conf->ssl_options */
diff --git a/src/cfgparse.c b/src/cfgparse.c
index b98f645..4d788dd 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -690,7 +690,6 @@
struct peer *newpeer = NULL;
const char *err;
struct bind_conf *bind_conf;
- struct listener *l;
int err_code = 0;
char *errmsg = NULL;
static int bind_line, peer_line;
@@ -717,6 +716,7 @@
bind_conf->maxaccept = 1;
bind_conf->accept = session_accept_fd;
+ bind_conf->options |= BC_O_UNLIMITED; /* don't make the peers subject to global limits */
if (*args[0] == 'b') {
struct listener *l;
@@ -743,11 +743,12 @@
err_code |= ERR_FATAL;
goto out;
}
+
/*
* Newly allocated listener is at the end of the list
*/
l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
- l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
+
global.maxsock++; /* for the listening socket */
bind_line = 1;
@@ -949,6 +950,7 @@
bind_conf->maxaccept = 1;
bind_conf->accept = session_accept_fd;
+ bind_conf->options |= BC_O_UNLIMITED; /* don't make the peers subject to global limits */
if (!LIST_ISEMPTY(&bind_conf->listeners)) {
ha_alert("parsing [%s:%d] : One listener per \"peers\" section is authorized but another is already configured at [%s:%d].\n", file, linenum, bind_conf->file, bind_conf->line);
@@ -967,11 +969,6 @@
goto out;
}
- /*
- * Newly allocated listener is at the end of the list
- */
- l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
- l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
global.maxsock++; /* for the listening socket */
}
else if (strcmp(args[0], "shards") == 0) {
diff --git a/src/cli.c b/src/cli.c
index b133b5f..679eb5a 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -553,9 +553,9 @@
bind_conf->accept = session_accept_fd;
bind_conf->nice = -64; /* we want to boost priority for local stats */
+ bind_conf->options |= BC_O_UNLIMITED; /* don't make the peers subject to global limits */
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
- l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
global.maxsock++; /* for the listening socket */
}
}
@@ -3046,10 +3046,9 @@
bind_conf->accept = session_accept_fd;
bind_conf->nice = -64; /* we want to boost priority for local stats */
+ bind_conf->options |= BC_O_UNLIMITED; /* don't make the peers subject to global limits */
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
- /* don't make the peers subject to global limits and don't close it in the master */
- l->options |= LI_O_UNLIMITED;
l->rx.flags |= RX_F_MWORKER; /* we are keeping this FD in the master */
global.maxsock++; /* for the listening socket */
}
@@ -3113,9 +3112,9 @@
bind_conf->accept = session_accept_fd;
bind_conf->nice = -64; /* we want to boost priority for local stats */
+ bind_conf->options |= BC_O_UNLIMITED | BC_O_NOSTOP;
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
- l->options |= (LI_O_UNLIMITED | LI_O_NOSTOP);
HA_ATOMIC_INC(&unstoppable_jobs);
/* it's a sockpair but we don't want to keep the fd in the master */
l->rx.flags &= ~RX_F_INHERITED;
diff --git a/src/listener.c b/src/listener.c
index 7ff21f0..b7b3b22 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -152,7 +152,7 @@
* may only be done once l->bind_conf->accept() has accepted the
* connection.
*/
- if (!(li->options & LI_O_UNLIMITED)) {
+ if (!(li->bind_conf->options & BC_O_UNLIMITED)) {
HA_ATOMIC_UPDATE_MAX(&global.sps_max,
update_freq_ctr(&global.sess_per_sec, 1));
if (li->bind_conf && li->bind_conf->options & BC_O_USE_SSL) {
@@ -345,7 +345,7 @@
{
struct proxy *px = l->bind_conf->frontend;
- if (l->options & LI_O_NOSTOP) {
+ if (l->bind_conf->options & BC_O_NOSTOP) {
/* master-worker sockpairs are never closed but don't count as a
* job.
*/
@@ -848,7 +848,7 @@
*/
max_accept = l->bind_conf->maxaccept ? l->bind_conf->maxaccept : 1;
- if (!(l->options & LI_O_UNLIMITED) && global.sps_lim) {
+ if (!(l->bind_conf->options & BC_O_UNLIMITED) && global.sps_lim) {
int max = freq_ctr_remain(&global.sess_per_sec, global.sps_lim, 0);
if (unlikely(!max)) {
@@ -861,7 +861,7 @@
max_accept = max;
}
- if (!(l->options & LI_O_UNLIMITED) && global.cps_lim) {
+ if (!(l->bind_conf->options & BC_O_UNLIMITED) && global.cps_lim) {
int max = freq_ctr_remain(&global.conn_per_sec, global.cps_lim, 0);
if (unlikely(!max)) {
@@ -874,7 +874,7 @@
max_accept = max;
}
#ifdef USE_OPENSSL
- if (!(l->options & LI_O_UNLIMITED) && global.ssl_lim &&
+ if (!(l->bind_conf->options & BC_O_UNLIMITED) && global.ssl_lim &&
l->bind_conf && l->bind_conf->options & BC_O_USE_SSL) {
int max = freq_ctr_remain(&global.ssl_per_sec, global.ssl_lim, 0);
@@ -943,7 +943,7 @@
} while (!_HA_ATOMIC_CAS(&p->feconn, &count, next_feconn));
}
- if (!(l->options & LI_O_UNLIMITED)) {
+ if (!(l->bind_conf->options & BC_O_UNLIMITED)) {
do {
count = actconn;
if (unlikely(count >= global.maxconn)) {
@@ -979,7 +979,7 @@
_HA_ATOMIC_DEC(&l->nbconn);
if (p)
_HA_ATOMIC_DEC(&p->feconn);
- if (!(l->options & LI_O_UNLIMITED))
+ if (!(l->bind_conf->options & BC_O_UNLIMITED))
_HA_ATOMIC_DEC(&actconn);
continue;
@@ -1001,7 +1001,7 @@
proxy_inc_fe_conn_ctr(l, p);
}
- if (!(l->options & LI_O_UNLIMITED)) {
+ if (!(l->bind_conf->options & BC_O_UNLIMITED)) {
count = update_freq_ctr(&global.conn_per_sec, 1);
HA_ATOMIC_UPDATE_MAX(&global.cps_max, count);
}
@@ -1155,12 +1155,12 @@
* may only be done once l->bind_conf->accept() has accepted the
* connection.
*/
- if (!(l->options & LI_O_UNLIMITED)) {
+ if (!(l->bind_conf->options & BC_O_UNLIMITED)) {
count = update_freq_ctr(&global.sess_per_sec, 1);
HA_ATOMIC_UPDATE_MAX(&global.sps_max, count);
}
#ifdef USE_OPENSSL
- if (!(l->options & LI_O_UNLIMITED) &&
+ if (!(l->bind_conf->options & BC_O_UNLIMITED) &&
l->bind_conf && l->bind_conf->options & BC_O_USE_SSL) {
count = update_freq_ctr(&global.ssl_per_sec, 1);
HA_ATOMIC_UPDATE_MAX(&global.ssl_max, count);
@@ -1237,7 +1237,7 @@
{
struct proxy *fe = l->bind_conf->frontend;
- if (!(l->options & LI_O_UNLIMITED))
+ if (!(l->bind_conf->options & BC_O_UNLIMITED))
_HA_ATOMIC_DEC(&actconn);
if (fe)
_HA_ATOMIC_DEC(&fe->feconn);