MINOR: check: do not increment global maxsock at runtime
global maxsock is used to estimate a number of fd to reserve for
internal use, such as checks. It is incremented at startup with the info
from the config file.
Disable this incrementation in checks functions at runtime. First, it
currently serves no purpose to increment it after startup. Worse, it may
lead to out-of-bound accesse on the fdtab.
This will be useful to initiate checks for dynamic servers.
diff --git a/src/check.c b/src/check.c
index 1391d11..c2ab8e8 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1647,7 +1647,13 @@
goto out;
}
srv->check.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED;
- global.maxsock++;
+
+ /* Only increment maxsock for servers from the configuration. Dynamic
+ * servers at the moment are not taken into account for the estimation
+ * of the resources limits.
+ */
+ if (global.mode & MODE_STARTING)
+ global.maxsock++;
out:
return ret;
@@ -1696,7 +1702,13 @@
srv->agent.inter = srv->check.inter;
srv->agent.state |= CHK_ST_CONFIGURED | CHK_ST_ENABLED | CHK_ST_AGENT;
- global.maxsock++;
+
+ /* Only increment maxsock for servers from the configuration. Dynamic
+ * servers at the moment are not taken into account for the estimation
+ * of the resources limits.
+ */
+ if (global.mode & MODE_STARTING)
+ global.maxsock++;
out:
return ret;
@@ -1937,7 +1949,13 @@
goto error;
}
- global.maxsock++;
+ /* Only increment maxsock for servers from the configuration. Dynamic
+ * servers at the moment are not taken into account for the estimation
+ * of the resources limits.
+ */
+ if (global.mode & MODE_STARTING)
+ global.maxsock++;
+
set_srv_agent_port(srv, atol(args[*cur_arg + 1]));
out:
@@ -2304,7 +2322,13 @@
goto error;
}
- global.maxsock++;
+ /* Only increment maxsock for servers from the configuration. Dynamic
+ * servers at the moment are not taken into account for the estimation
+ * of the resources limits.
+ */
+ if (global.mode & MODE_STARTING)
+ global.maxsock++;
+
srv->check.port = atol(args[*cur_arg+1]);
/* if agentport was never set, we can use port */
if (!(srv->flags & SRV_F_AGENTPORT))