]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: helper to write an response message and close
authorWilliam Lallemand <wlallemand@haproxy.com>
Fri, 26 Oct 2018 12:47:48 +0000 (14:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 28 Oct 2018 13:13:35 +0000 (14:13 +0100)
pcli_reply_and_close() writes a message to the client and close the
connection. To be used only in the CLI proxy.

src/cli.c

index 5e8df25e9dc72d78c337e657f4bf044ea130b6ee..e1b527465fbe83d639cfbf9a84305eb776e45ccf 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1635,6 +1635,14 @@ void pcli_write_prompt(struct stream *s)
 
 /* The pcli_* functions are used for the CLI proxy in the master */
 
+void pcli_reply_and_close(struct stream *s, const char *msg)
+{
+       struct buffer *buf = get_trash_chunk();
+
+       chunk_initstr(buf, msg);
+       stream_int_retnclose(&s->si[0], buf);
+}
+
 static enum obj_type *pcli_pid_to_server(int proc_pid)
 {
        struct mworker_proc *child;
@@ -1894,8 +1902,8 @@ read_again:
                        s->pcli_next_pid = target_pid;
                        pcli_write_prompt(s);
                } else {
-                       // TODO: pcli_reply() error
                        s->pcli_next_pid = 0;
+                       pcli_reply_and_close(s, "Can't find the target CLI!\n");
                }
 
                /* we trimmed things but we might have other commands to consume */