From: Olivier Houchard Date: Wed, 29 Jul 2026 21:37:32 +0000 (+0200) Subject: MINOR: cli: Report the tgid along the FD in "show sess" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcb93d1c0f708a52432b5888f6b1f50edbe1876b;p=thirdparty%2Fhaproxy.git MINOR: cli: Report the tgid along the FD in "show sess" With per-thread-group FD tables, an FD number alone is ambiguous: it is only meaningful within the thread group of the stream that uses it. So display the FDs of the "show sess" output in the "tgid/fd" form already used by "show fd", both in the one-line format and in the detailed one. In the detailed output, the FD state, update and thread masks are also read from the owner group's table rather than from the calling thread's one, which would report an unrelated entry when the tables are not shared. --- diff --git a/src/stream.c b/src/stream.c index 76414565d..29767d7bb 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3474,6 +3474,8 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx struct connection *conn; struct appctx *tmpctx; uint64_t request_ts; + uint strm_tgid = ha_thread_info[strm->task->tid].tgid; + const struct fdtab *strm_fdtab = ha_tgroup_ctx[strm_tgid - 1].fdtab; pfx = pfx ? pfx : ""; @@ -3697,12 +3699,13 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx obj_base_ptr(conn->target)); chunk_appendf(buf, - "%s flags=0x%08x fd=%d fd.state=%02x updt=%d fd.tmask=0x%lx\n", pfx, + "%s flags=0x%08x fd=%u/%d fd.state=%02x updt=%d fd.tmask=0x%lx\n", pfx, conn->flags, + strm_tgid, conn_fd(conn), - conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].state : 0, - conn_fd(conn) >= 0 ? !!(fdtab[conn->handle.fd].update_mask & ti->ltid_bit) : 0, - conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].thread_mask: 0); + conn_fd(conn) >= 0 ? strm_fdtab[conn->handle.fd].state : 0, + conn_fd(conn) >= 0 ? !!(strm_fdtab[conn->handle.fd].update_mask & ti->ltid_bit) : 0, + conn_fd(conn) >= 0 ? strm_fdtab[conn->handle.fd].thread_mask: 0); } else if ((tmpctx = sc_appctx(scf)) != NULL) { chunk_appendf(buf, @@ -3758,12 +3761,13 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx obj_base_ptr(conn->target)); chunk_appendf(buf, - "%s flags=0x%08x fd=%d fd.state=%02x updt=%d fd.tmask=0x%lx\n", pfx, + "%s flags=0x%08x fd=%u/%d fd.state=%02x updt=%d fd.tmask=0x%lx\n", pfx, conn->flags, + strm_tgid, conn_fd(conn), - conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].state : 0, - conn_fd(conn) >= 0 ? !!(fdtab[conn->handle.fd].update_mask & ti->ltid_bit) : 0, - conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].thread_mask: 0); + conn_fd(conn) >= 0 ? strm_fdtab[conn->handle.fd].state : 0, + conn_fd(conn) >= 0 ? !!(strm_fdtab[conn->handle.fd].update_mask & ti->ltid_bit) : 0, + conn_fd(conn) >= 0 ? strm_fdtab[conn->handle.fd].thread_mask: 0); } else if ((tmpctx = sc_appctx(scb)) != NULL) { chunk_appendf(buf, @@ -4216,8 +4220,9 @@ static int cli_io_handler_dump_sess(struct appctx *appctx) TICKS_TO_MS(1000)) : ""); conn = sc_conn(curr_strm->scf); - chunk_appendf(&trash," scf=[%d,%1xh,fd=%d", - curr_strm->scf->state, curr_strm->scf->flags, conn_fd(conn)); + chunk_appendf(&trash," scf=[%d,%1xh,fd=%u/%d", + curr_strm->scf->state, curr_strm->scf->flags, + ha_thread_info[curr_strm->task->tid].tgid, conn_fd(conn)); chunk_appendf(&trash, ",rex=%s", sc_ep_rcv_ex(curr_strm->scf) ? human_time(TICKS_TO_MS(sc_ep_rcv_ex(curr_strm->scf) - now_ms), @@ -4228,8 +4233,9 @@ static int cli_io_handler_dump_sess(struct appctx *appctx) TICKS_TO_MS(1000)) : ""); conn = sc_conn(curr_strm->scb); - chunk_appendf(&trash, " scb=[%d,%1xh,fd=%d", - curr_strm->scb->state, curr_strm->scb->flags, conn_fd(conn)); + chunk_appendf(&trash, " scb=[%d,%1xh,fd=%u/%d", + curr_strm->scb->state, curr_strm->scb->flags, + ha_thread_info[curr_strm->task->tid].tgid, conn_fd(conn)); chunk_appendf(&trash, ",rex=%s", sc_ep_rcv_ex(curr_strm->scb) ? human_time(TICKS_TO_MS(sc_ep_rcv_ex(curr_strm->scb) - now_ms),