]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker/cli: the mcli_reload bind_conf only send the reload status
authorWilliam Lallemand <wlallemand@haproxy.org>
Sat, 24 Sep 2022 14:14:50 +0000 (16:14 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Sat, 24 Sep 2022 14:35:23 +0000 (16:35 +0200)
Upon a reload with the master CLI, the FD of the master CLI session is
received by the internal socketpair listener.

This session is used to display the status of the reload and then will
close.

include/haproxy/stream-t.h
src/cli.c

index 0d4c691c889dc840543068feaa8758c11d154d89..1ec40f513ee092865410889e927450e659a850fd 100644 (file)
@@ -131,6 +131,7 @@ static forceinline char *strm_show_flags(char *buf, size_t len, const char *deli
 
 #define PCLI_F_PROMPT   0x10000
 #define PCLI_F_PAYLOAD  0x20000
+#define PCLI_F_RELOAD   0x40000 /* this is the "reload" stream, quits after displaying reload status */
 
 
 /* error types reported on the streams for more accurate reporting.
index 1391345b3785707599a0a4a755a7dd5b3b1cfcad..7d91b2d962e3b2bfbca31e46ed7b8258f9b45dd8 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2682,6 +2682,13 @@ int pcli_wait_for_request(struct stream *s, struct channel *req, int an_bit)
        if ((s->pcli_flags & ACCESS_LVL_MASK) == ACCESS_LVL_NONE)
                s->pcli_flags |= strm_li(s)->bind_conf->level & ACCESS_LVL_MASK;
 
+       /* stream that comes from the reload listener only responses the reload
+        * status and quits */
+       if (!(s->pcli_flags & PCLI_F_RELOAD)
+           && strm_li(s)->bind_conf == mcli_reload_bind_conf)
+               goto send_status;
+
+
 read_again:
        /* if the channel is closed for read, we won't receive any more data
           from the client, but we don't want to forward this close to the
@@ -2755,6 +2762,13 @@ send_help:
        b_putblk(&req->buf, "help\n", 5);
        goto read_again;
 
+send_status:
+       s->pcli_flags |= PCLI_F_RELOAD;
+       /* dont' use ci_putblk here because SHUTW could have been sent */
+       b_reset(&req->buf);
+       b_putblk(&req->buf, "_loadstatus;quit\n", 17);
+       goto read_again;
+
 missing_data:
         if (req->flags & CF_SHUTR) {
                 /* There is no more request or a only a partial one and we