From e6f389d1a5a25e6728ac77b2d0701ec1f2611d06 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 2 Sep 2022 16:32:31 +0200 Subject: [PATCH] MINOR: mux-h1: provide a "show_sd" helper to output stream debugging info With this, it now becomes possible to see the state of each H1 stream from "show sess all". Example (added lines highlighted with '>'): 0x7fc9b40460a0: [02/Sep/2022:16:29:31.267228] id=49 proto=tcpv4 source=127.0.0.1:53548 flags=0xc4a, conn_retries=0, conn_exp= conn_et=0x000 srv_conn=0x2dc4b20, pend_pos=(nil) waiting=0 epoch=0 frontend=decrypt (id=2 mode=http), listener=? (id=3) addr=127.0.0.1:8001 backend=decrypt (id=2 mode=http) addr=127.0.0.1:25168 server=httpterm (id=1) addr=127.0.0.1:8000 task=0x7fc9b4046490 (state=0x00 nice=0 calls=4 rate=0 exp=3s tid=7(1/7) age=2s) txn=0x7fc9b4046650 flags=0x3000 meth=1 status=200 req.st=MSG_DONE rsp.st=MSG_DATA req.f=0x4c rsp.f=0x0d scf=0x7fc9b4046030 flags=0x00000080 state=EST endp=CONN,0x7fc9b4041f00,0x02804001 sub=1 > h1s=0x7fc9b4041f00 h1s.flg=0x104010 .sd.flg=0x2804001 .req.state=MSG_DONE .res.state=MSG_DATA > .meth=GET status=200 .sd.flg=0x02804001 .sc.flg=0x00000080 .sc.app=0x7fc9b40460a0 > .subs=0x7fc9b4046040(ev=1 tl=0x7fc9b4046540 tl.calls=9 tl.ctx=0x7fc9b4046030 tl.fct=sc_conn_io_cb) > h1c=0x7fc9b402b3f0 h1c.flg=0x302200 .sub=1 .ibuf=0@(nil)+0/0 .obuf=0@(nil)+0/0 co0=0x7fc9bc02e740 ctrl=tcpv4 xprt=RAW mux=H1 data=STRM target=LISTENER:0x2dc3c40 flags=0x00000300 fd=79 fd.state=421 updt=0 fd.tmask=0x80 scb=0x7fc9b4046590 flags=0x00000011 state=EST endp=CONN,0x7fc9b4048660,0x02840001 sub=0 > h1s=0x7fc9b4048660 h1s.flg=0x4010 .sd.flg=0x2840001 .req.state=MSG_DONE .res.state=MSG_DATA > .meth=GET status=200 .sd.flg=0x02840001 .sc.flg=0x00000011 .sc.app=0x7fc9b40460a0 .subs=(nil) > h1c=0x7fc9b4048490 h1c.flg=0x80002200 .sub=0 .ibuf=0@(nil)+0/0 .obuf=0@(nil)+0/0 co1=0x7fc9b4048270 ctrl=tcpv4 xprt=RAW mux=H1 data=STRM target=SERVER:0x2dc4b20 flags=0x00000300 fd=131 fd.state=10122 updt=0 fd.tmask=0x80 req=0x7fc9b40460c0 (f=0x49c40080 an=0x8000 pipe=0 tofwd=0 total=56) an_exp= rex= wex= buf=0x7fc9b40460c8 data=(nil) o=0 p=0 i=0 size=0 htx=0xdd90a0 flags=0x0 size=0 data=0 used=0 wrap=NO extra=0 res=0x7fc9b4046120 (f=0x80070202 an=0x4000000 pipe=0 tofwd=-1 total=603840788) an_exp= rex= wex= buf=0x7fc9b4046128 data=(nil) o=0 p=0 i=0 size=0 htx=0xdd90a0 flags=0x0 size=0 data=0 used=0 wrap=NO extra=0 --- src/mux_h1.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/mux_h1.c b/src/mux_h1.c index 06c8e5b0c..441ae3ee4 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -3987,6 +3987,27 @@ static int h1_show_fd(struct buffer *msg, struct connection *conn) return ret; } +/* for debugging with CLI's "show sess" command. May emit multiple lines, each + * new one being prefixed with , if is not NULL, otherwise a single + * line is used. Each field starts with a space so it's safe to print it after + * existing fields. + */ +static int h1_show_sd(struct buffer *msg, struct sedesc *sd, const char *pfx) +{ + struct h1s *h1s = sd->se; + int ret = 0; + + if (!h1s) + return ret; + + ret |= h1_dump_h1s_info(msg, h1s, pfx); + if (pfx) + chunk_appendf(msg, "\n%s", pfx); + chunk_appendf(msg, " h1c=%p", h1s->h1c); + ret |= h1_dump_h1c_info(msg, h1s->h1c, pfx); + return ret; +} + /* Add an entry in the headers map. Returns -1 on error and 0 on success. */ static int add_hdr_case_adjust(const char *from, const char *to, char **err) @@ -4272,6 +4293,7 @@ static const struct mux_ops mux_http_ops = { .shutr = h1_shutr, .shutw = h1_shutw, .show_fd = h1_show_fd, + .show_sd = h1_show_sd, .ctl = h1_ctl, .takeover = h1_takeover, .flags = MX_FL_HTX, @@ -4298,6 +4320,7 @@ static const struct mux_ops mux_h1_ops = { .shutr = h1_shutr, .shutw = h1_shutw, .show_fd = h1_show_fd, + .show_sd = h1_show_sd, .ctl = h1_ctl, .takeover = h1_takeover, .flags = MX_FL_HTX|MX_FL_NO_UPG,