]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: proxy: zombify proxies only when the expose-fd socket is bound
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 26 May 2017 16:19:55 +0000 (18:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 27 May 2017 05:02:25 +0000 (07:02 +0200)
When HAProxy is running with multiple processes and some listeners
arebound to processes, the unused sockets were not closed in the other
processes. The aim was to be able to send those listening sockets using
the -x option.

However to ensure the previous behavior which was to close those
sockets, we provided the "no-unused-socket" global option.

This patch changes this behavior, it will close unused sockets which are
not in the same process as an expose-fd socket, making the
"no-unused-socket" option useless.

The "no-unused-socket" option was removed in this patch.

doc/configuration.txt
src/cfgparse.c
src/haproxy.c

index f9bdf2add034c66fedddc752906100bda1d7a0ec..bd9a99f13c99a300e300d0b0068737a081295967 100644 (file)
@@ -587,7 +587,6 @@ The following keywords are supported in the "global" section :
    - nosplice
    - nogetaddrinfo
    - noreuseport
-   - no-unused-socket
    - spread-checks
    - server-state-base
    - server-state-file
@@ -1251,12 +1250,6 @@ noreuseport
   Disables the use of SO_REUSEPORT - see socket(7). It is equivalent to the
   command line argument "-dR".
 
-no-unused-socket
-  By default, each haproxy process keeps all sockets opened, event those that
-  are only used by another processes, so that any process can provide all the
-  sockets, to make reloads seamless. This option disables this, and close all
-  unused sockets, to save some file descriptors.
-
 spread-checks <0..50, in percent>
   Sometimes it is desirable to avoid sending agent and health checks to
   servers at exact intervals, for instance when many logical servers are
index f16732191335a821bf3afe0ce4a3abff3804752d..4c0e2d4f0ee43728948fc0fe36a6a60249d37227 100644 (file)
@@ -659,11 +659,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
                        goto out;
                global.tune.options &= ~GTUNE_USE_REUSEPORT;
        }
-       else if (!strcmp(args[0], "no-unused-socket")) {
-               if (alertif_too_many_args(0, file, linenum, args, &err_code))
-                       goto out;
-               global.tune.options &= ~GTUNE_SOCKET_TRANSFER;
-       }
        else if (!strcmp(args[0], "quiet")) {
                if (alertif_too_many_args(0, file, linenum, args, &err_code))
                        goto out;
index 261b2136a124708fc5d4181fa831d87ab4e68dd7..5ccebd1054d750fe1784838e0ffb1d3a456eec42 100644 (file)
@@ -859,7 +859,6 @@ static void init(int argc, char **argv)
 #if defined(SO_REUSEPORT)
        global.tune.options |= GTUNE_USE_REUSEPORT;
 #endif
-       global.tune.options |= GTUNE_SOCKET_TRANSFER;
 
        pid = getpid();
        progname = *argv;
@@ -2165,6 +2164,24 @@ int main(int argc, char **argv)
                        exit(0); /* parent must leave */
                }
 
+               /* pass through every cli socket, and check if it's bound to
+                * the current process and if it exposes listeners sockets.
+                * Caution: the GTUNE_SOCKET_TRANSFER is now set after the fork.
+                * */
+
+               if (global.stats_fe) {
+                       struct bind_conf *bind_conf;
+
+                       list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
+                               if (bind_conf->level & ACCESS_FD_LISTENERS) {
+                                       if (!bind_conf->bind_proc || bind_conf->bind_proc & (1UL << proc)) {
+                                               global.tune.options |= GTUNE_SOCKET_TRANSFER;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
                /* we might have to unbind some proxies from some processes */
                px = proxy;
                while (px != NULL) {