]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cli: write a prompt for the CLI proxy of the master
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 26 Oct 2018 12:47:47 +0000 (14:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 28 Oct 2018 13:13:34 +0000 (14:13 +0100)
Write a prompt with the PID of the target or master.
It's always activated for now.

Example:
    1234>
    master>

src/cli.c

index 6e7c3d0c9be0e78daa81663d060b44fd6b866e9f..5e8df25e9dc72d78c337e657f4bf044ea130b6ee 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1620,6 +1620,18 @@ static int cli_parse_simple(char **args, char *payload, struct appctx *appctx, v
        return 1;
 }
 
+void pcli_write_prompt(struct stream *s)
+{
+       struct buffer *msg = get_trash_chunk();
+       struct channel *oc = si_oc(&s->si[0]);
+
+       if (s->pcli_next_pid == 0)
+               chunk_appendf(msg, "master> ");
+       else
+               chunk_appendf(msg, "%d> ", s->pcli_next_pid);
+       co_inject(oc, msg->area, msg->data);
+}
+
 
 /* The pcli_* functions are used for the CLI proxy in the master */
 
@@ -1880,7 +1892,7 @@ read_again:
                   command for this session */
                if (target_pid > -1) {
                        s->pcli_next_pid = target_pid;
-                       // TODO: pcli_reply the prompt
+                       pcli_write_prompt(s);
                } else {
                        // TODO: pcli_reply() error
                        s->pcli_next_pid = 0;
@@ -1922,6 +1934,8 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
        if ((rep->flags & (CF_SHUTR|CF_READ_NULL))) {
                /* stream cleanup */
 
+               pcli_write_prompt(s);
+
                s->si[1].flags |= SI_FL_NOLINGER | SI_FL_NOHALF;
                si_shutr(&s->si[1]);
                si_shutw(&s->si[1]);