]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: log: old processes with log foward section don't die on soft stop.
authorEmeric Brun <ebrun@haproxy.com>
Wed, 7 Oct 2020 08:13:10 +0000 (10:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Oct 2020 15:17:27 +0000 (17:17 +0200)
Old processes didn't die if a log foward section is declared and
a soft stop is requested.

This patch fix this issue and should be backpored in banches including
the log forward feature.

src/haproxy.c
src/proxy.c

index 49f3fbd89d3b1454e36dcc19d5da25e98d1e6017..eb4e9699a3b614fe89b3291236ab8f94c8e919ff 100644 (file)
@@ -3499,6 +3499,20 @@ int main(int argc, char **argv)
                        px = px->next;
                }
 
+               /* we might have to unbind some log forward proxies from some processes */
+               px = cfg_log_forward;
+               while (px != NULL) {
+                       if (px->bind_proc && px->state != PR_STSTOPPED) {
+                               if (!(px->bind_proc & (1UL << proc))) {
+                                       if (global.tune.options & GTUNE_SOCKET_TRANSFER)
+                                               zombify_proxy(px);
+                                       else
+                                               stop_proxy(px);
+                               }
+                       }
+                       px = px->next;
+               }
+
                /* we might have to unbind some peers sections from some processes */
                for (curpeers = cfg_peers; curpeers; curpeers = curpeers->next) {
                        if (!curpeers->peers_fe)
index 18cdf426e0c86e1c217ca41c3b5ef7ccf71b06aa..eeb492e534b7d9aed8088f4ea5462f314a68d6b8 100644 (file)
@@ -1275,6 +1275,28 @@ void soft_stop(void)
                        stop_proxy(prs->peers_fe);
                prs = prs->next;
        }
+
+       p = cfg_log_forward;
+       while (p) {
+               /* Zombie proxy, let's close the file descriptors */
+               if (p->state == PR_STSTOPPED &&
+                   !LIST_ISEMPTY(&p->conf.listeners) &&
+                   LIST_ELEM(p->conf.listeners.n,
+                   struct listener *, by_fe)->state > LI_ASSIGNED) {
+                       struct listener *l;
+                       list_for_each_entry(l, &p->conf.listeners, by_fe) {
+                               if (l->state > LI_ASSIGNED)
+                                       close(l->rx.fd);
+                               l->state = LI_INIT;
+                       }
+               }
+
+               if (p->state != PR_STSTOPPED) {
+                       stop_proxy(p);
+               }
+               p = p->next;
+       }
+
        /* signal zero is used to broadcast the "stopping" event */
        signal_handler(0);
 }