]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stream: make stream_dump() always multi-line
authorWilly Tarreau <w@1wt.eu>
Thu, 28 Sep 2023 06:06:22 +0000 (08:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 29 Sep 2023 07:20:27 +0000 (09:20 +0200)
There used to be two working modes for this function, a single-line one
and a multi-line one, the difference being made on the "eol" argument
which could contain either a space or an LF (and with the prefix being
adjusted accordingly). Let's get rid of the single-line mode as it's
what limits the output contents because it's difficult to produce
exploitable structured data this way. It was only used in the rare case
of spinning streams and applets and these are the ones lacking info. Now
a spinning stream produces:

[ALERT]    (3511) : A bogus STREAM [0x227e7b0] is spinning at 5581202 calls per second and refuses to die, aborting now! Please report this error to developers:
  strm=0x227e7b0,c4a src=127.0.0.1 fe=public be=public dst=s1
  txn=0x2041650,3000 txn.req=MSG_DONE,4c txn.rsp=MSG_RPBEFORE,0
  rqf=1840000 rqa=8000 rpf=80000000 rpa=1400000
  scf=0x24af280,EST,482 scb=0x24af430,EST,1411
  af=(nil),0 sab=(nil),0
  cof=0x7fdb28026630,300:H1(0x24a6f60)/RAW((nil))/tcpv4(33)
  cob=0x23199f0,10000300:H1(0x24af630)/RAW((nil))/tcpv4(32)
  filters={}
  call trace(11):
  (...)

include/haproxy/stream.h
src/debug.c
src/stream.c

index 19ef92c35032f09181bb87ff3c4cb05ccf10b907..55a77bd39d4c13dd870c25b3368cb861ed46e911 100644 (file)
@@ -66,7 +66,7 @@ int stream_set_http_mode(struct stream *s, const struct mux_proto_list *mux_prot
 
 /* kill a stream and set the termination flags to <why> (one of SF_ERR_*) */
 void stream_shutdown(struct stream *stream, int why);
-void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx, char eol);
+void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx);
 void stream_dump_and_crash(enum obj_type *obj, int rate);
 
 struct ist stream_generate_unique_id(struct stream *strm, struct list *format);
index 89c7a53de20d78df572a0019b8be03e409631af0..24e9167448d2c67d63d6de5dbdacb568a3b49093 100644 (file)
@@ -325,7 +325,7 @@ void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx)
                s = sc_strm(((struct stconn *)task->context));
 
        if (s)
-               stream_dump(buf, s, pfx, '\n');
+               stream_dump(buf, s, pfx);
 
 #ifdef USE_LUA
        hlua = NULL;
index 35759037c0d17a3d178b28a55d1533e998306e6b..d95b92041fd5b11d68bb594ccbc3371bfcbc0082 100644 (file)
@@ -2809,7 +2809,7 @@ void stream_shutdown(struct stream *stream, int why)
  * preliminary be prepared by its caller, with each line prepended by prefix
  * <pfx>, and each line terminated by character <eol>.
  */
-void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx, char eol)
+void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx)
 {
        const struct stconn *scf, *scb;
        const struct connection  *cof, *cob;
@@ -2819,6 +2819,7 @@ void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx, ch
        const char *dst = "unknown";
        char pn[INET6_ADDRSTRLEN];
        const struct channel *req, *res;
+       char eol = '\n';
 
        if (!s) {
                chunk_appendf(buf, "%sstrm=%p%c", pfx, s, eol);
@@ -2895,9 +2896,9 @@ void stream_dump_and_crash(enum obj_type *obj, int rate)
        }
 
        chunk_reset(&trash);
-       stream_dump(&trash, s, "", ' ');
+       stream_dump(&trash, s, "  ");
 
-       chunk_appendf(&trash, "filters={");
+       chunk_appendf(&trash, "  filters={");
        if (HAS_FILTERS(s)) {
                struct filter *filter;
 
@@ -2923,8 +2924,8 @@ void stream_dump_and_crash(enum obj_type *obj, int rate)
 
        memprintf(&msg,
                  "A bogus %s [%p] is spinning at %d calls per second and refuses to die, "
-                 "aborting now! Please report this error to developers "
-                 "[%s]\n",
+                 "aborting now! Please report this error to developers:\n"
+                 "%s\n",
                  obj_type_name(obj), ptr, rate, trash.area);
 
        ha_alert("%s", msg);