mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: cli: helper to write an response message and close
pcli_reply_and_close() writes a message to the client and close the connection. To be used only in the CLI proxy.
This commit is contained in:
parent
2f4ce202d7
commit
deeaa593f3
10
src/cli.c
10
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 */
|
/* 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)
|
static enum obj_type *pcli_pid_to_server(int proc_pid)
|
||||||
{
|
{
|
||||||
struct mworker_proc *child;
|
struct mworker_proc *child;
|
||||||
@ -1894,8 +1902,8 @@ read_again:
|
|||||||
s->pcli_next_pid = target_pid;
|
s->pcli_next_pid = target_pid;
|
||||||
pcli_write_prompt(s);
|
pcli_write_prompt(s);
|
||||||
} else {
|
} else {
|
||||||
// TODO: pcli_reply() error
|
|
||||||
s->pcli_next_pid = 0;
|
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 */
|
/* we trimmed things but we might have other commands to consume */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user