]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
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)
committerWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2025 16:18:00 +0000 (17:18 +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.

src/stream.c

index f673c4f4fbd4188547af90fa0162c21a9a56485e..1a8e4ee1bf4bb00838a8d42460d8c30383c12e0c 100644 (file)
@@ -3561,8 +3561,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)) {
@@ -3593,8 +3594,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)) {