BUG/MINOR: stream: do not call co_data() from __strm_dump_to_buffer()
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2025 16:18:00 +0000 (17:18 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Feb 2025 15:23:05 +0000 (16:23 +0100)
co_data() was instrumented to detect cases where c->output > data and
emits a warning if that's not correct. The problem is that it happens
quite a bit during "show threads" if it interrupts traffic anywhere,
and that in some environments building with -DDEBUG_STRICT_ACTION=3,
it will kill the process.

Let's just open-code the channel functions that make access to co_data(),
there are not that many and the operations remain very simple.

This can be backported to 3.1. It didn't trigger in earlier versions
because they didn't have this CHECK_IF_HOT() test.

(cherry picked from commit 9d5bd47634707963ac6be4fc90e64feded174d0a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/stream.c

index 5e39ba2..bf3a433 100644 (file)
@@ -3579,8 +3579,9 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
                     human_time(TICKS_TO_MS(strm->req.analyse_exp - now_ms),
                                TICKS_TO_MS(1000)) : "<NEVER>",
                     &strm->req.buf,
-                    b_orig(&strm->req.buf), (unsigned int)co_data(&strm->req),
-                    (unsigned int)ci_head_ofs(&strm->req), (unsigned int)ci_data(&strm->req),
+                    b_orig(&strm->req.buf), (unsigned int)strm->req.output,
+                    (unsigned int)b_peek_ofs(&strm->req.buf, strm->req.output),
+                    (unsigned int)(c_data(&strm->req) - strm->req.output),
                     (unsigned int)strm->req.buf.size);
 
        if (IS_HTX_STRM(strm)) {
@@ -3611,8 +3612,9 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
                     human_time(TICKS_TO_MS(strm->res.analyse_exp - now_ms),
                                TICKS_TO_MS(1000)) : "<NEVER>",
                     &strm->res.buf,
-                    b_orig(&strm->res.buf), (unsigned int)co_data(&strm->res),
-                    (unsigned int)ci_head_ofs(&strm->res), (unsigned int)ci_data(&strm->res),
+                    b_orig(&strm->res.buf), (unsigned int)strm->res.output,
+                    (unsigned int)b_peek_ofs(&strm->res.buf, strm->res.output),
+                    (unsigned int)(c_data(&strm->res) - strm->res.output),
                     (unsigned int)strm->res.buf.size);
 
        if (IS_HTX_STRM(strm)) {