From: Willy Tarreau Date: Fri, 20 Oct 2023 15:32:13 +0000 (+0200) Subject: MINOR: mux-h2/traces: explicitly show the error/refused stream states X-Git-Tag: v2.9-dev8~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1deac6f99a400eb32917f456c179579509293f88;p=thirdparty%2Fhaproxy.git MINOR: mux-h2/traces: explicitly show the error/refused stream states Sometimes it's unclear whether a stream is still open or closed when certain traces are emitted, for example when the stream was refused, because the reported pointer and ID in fact correspond to the refused stream. And for closed streams, no pointer/name is printed, leaving some confusion about the state. This patch makes the situation easier to analyse by explicitly reporting "h2s=CLO" on closed/error/refused streams so that we don't waste time comparing pointers and we instantly know the stream is closed. Now instead of emitting: [03|h2|5|mux_h2.c:2874] h2c_frt_handle_headers(): leaving on error : h2c=0x7fdfa8026820(F,FRE) dsi=201 h2s=0x9fdb60(0,CLO) It will emit: [03|h2|5|mux_h2.c:2874] h2c_frt_handle_headers(): leaving on error : h2c=0x7fdfa8026820(F,FRE) dsi=201 h2s=CLO --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 2fb8311642..8544dcc52a 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -516,8 +516,10 @@ static void h2_trace(enum trace_level level, uint64_t mask, const struct trace_s chunk_appendf(&trace_buf, " dsi=%d", h2c->dsi); if (h2s == h2_idle_stream) chunk_appendf(&trace_buf, " h2s=IDL"); - else if (h2s != h2_closed_stream) + else if (h2s != h2_closed_stream && h2s != h2_refused_stream && h2s != h2_error_stream) chunk_appendf(&trace_buf, " h2s=%p(%d,%s)", h2s, h2s->id, h2s_st_to_str(h2s->st)); + else if (h2c->dsi > 0) // don't show that before sid is known + chunk_appendf(&trace_buf, " h2s=CLO"); if (h2s->id && h2s->errcode) chunk_appendf(&trace_buf, " err=%s/%02x", h2_err_str(h2s->errcode), h2s->errcode); } @@ -2859,7 +2861,7 @@ static struct h2s *h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s) h2_release_buf(h2c, &rxbuf); h2c->st0 = H2_CS_FRAME_E; - TRACE_USER("rejected H2 request", H2_EV_RX_FRAME|H2_EV_RX_HDR|H2_EV_STRM_NEW|H2_EV_STRM_END, h2c->conn, 0, &rxbuf); + TRACE_USER("rejected H2 request", H2_EV_RX_FRAME|H2_EV_RX_HDR|H2_EV_STRM_NEW|H2_EV_STRM_END, h2c->conn, h2s, &rxbuf); TRACE_DEVEL("leaving on error", H2_EV_RX_FRAME|H2_EV_RX_HDR, h2c->conn, h2s); return h2s; }