mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
CLEANUP: cli: make "show fd" use a const connection to access other fields
Over time the code has uglified, casting fdt.owner as a struct connection for about everything. Let's have a const struct connection* there and take this opportunity for passing all fields as const as well. Additionally a misplaced closing parenthesis on the output was fixed.
This commit is contained in:
parent
45fd1030d5
commit
eb0595d039
28
src/cli.c
28
src/cli.c
@ -1027,11 +1027,12 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
|
|||||||
*/
|
*/
|
||||||
while (fd >= 0 && fd < global.maxsock) {
|
while (fd >= 0 && fd < global.maxsock) {
|
||||||
struct fdtab fdt;
|
struct fdtab fdt;
|
||||||
struct listener *li = NULL;
|
const struct listener *li = NULL;
|
||||||
struct server *sv = NULL;
|
const struct server *sv = NULL;
|
||||||
struct proxy *px = NULL;
|
const struct proxy *px = NULL;
|
||||||
|
const struct connection *conn = NULL;
|
||||||
const struct mux_ops *mux = NULL;
|
const struct mux_ops *mux = NULL;
|
||||||
void *ctx = NULL;
|
const void *ctx = NULL;
|
||||||
uint32_t conn_flags = 0;
|
uint32_t conn_flags = 0;
|
||||||
int is_back = 0;
|
int is_back = 0;
|
||||||
|
|
||||||
@ -1047,13 +1048,14 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
|
|||||||
goto skip; // closed
|
goto skip; // closed
|
||||||
}
|
}
|
||||||
else if (fdt.iocb == sock_conn_iocb) {
|
else if (fdt.iocb == sock_conn_iocb) {
|
||||||
conn_flags = ((struct connection *)fdt.owner)->flags;
|
conn = (const struct connection *)fdt.owner;
|
||||||
mux = ((struct connection *)fdt.owner)->mux;
|
conn_flags = conn->flags;
|
||||||
ctx = ((struct connection *)fdt.owner)->ctx;
|
mux = conn->mux;
|
||||||
li = objt_listener(((struct connection *)fdt.owner)->target);
|
ctx = conn->ctx;
|
||||||
sv = objt_server(((struct connection *)fdt.owner)->target);
|
li = objt_listener(conn->target);
|
||||||
px = objt_proxy(((struct connection *)fdt.owner)->target);
|
sv = objt_server(conn->target);
|
||||||
is_back = conn_is_back((struct connection *)fdt.owner);
|
px = objt_proxy(conn->target);
|
||||||
|
is_back = conn_is_back(conn);
|
||||||
}
|
}
|
||||||
else if (fdt.iocb == sock_accept_iocb)
|
else if (fdt.iocb == sock_accept_iocb)
|
||||||
li = fdt.owner;
|
li = fdt.owner;
|
||||||
@ -1104,11 +1106,13 @@ static int cli_io_handler_show_fd(struct appctx *appctx)
|
|||||||
listener_state_str(li),
|
listener_state_str(li),
|
||||||
li->bind_conf->frontend->id);
|
li->bind_conf->frontend->id);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
chunk_appendf(&trash, ")");
|
||||||
|
|
||||||
#ifdef DEBUG_FD
|
#ifdef DEBUG_FD
|
||||||
chunk_appendf(&trash, " evcnt=%u", fdtab[fd].event_count);
|
chunk_appendf(&trash, " evcnt=%u", fdtab[fd].event_count);
|
||||||
#endif
|
#endif
|
||||||
chunk_appendf(&trash, ")\n");
|
chunk_appendf(&trash, "\n");
|
||||||
|
|
||||||
if (ci_putchk(si_ic(si), &trash) == -1) {
|
if (ci_putchk(si_ic(si), &trash) == -1) {
|
||||||
si_rx_room_blk(si);
|
si_rx_room_blk(si);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user