From: Willy Tarreau Date: Thu, 28 Sep 2023 06:06:22 +0000 (+0200) Subject: MINOR: stream: make stream_dump() always multi-line X-Git-Tag: v2.9-dev7~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5743eeea885ef93bb9c661106cd7dc0305d374de;p=thirdparty%2Fhaproxy.git MINOR: stream: make stream_dump() always multi-line 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): (...) --- diff --git a/include/haproxy/stream.h b/include/haproxy/stream.h index 19ef92c350..55a77bd39d 100644 --- a/include/haproxy/stream.h +++ b/include/haproxy/stream.h @@ -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 (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); diff --git a/src/debug.c b/src/debug.c index 89c7a53de2..24e9167448 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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; diff --git a/src/stream.c b/src/stream.c index 35759037c0..d95b92041f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -2809,7 +2809,7 @@ void stream_shutdown(struct stream *stream, int why) * preliminary be prepared by its caller, with each line prepended by prefix * , and each line terminated by character . */ -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);