]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: Show IN/OUT buffers in trace messages when used
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 11 Jan 2024 09:02:47 +0000 (10:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Feb 2024 14:03:30 +0000 (15:03 +0100)
The function dumping applet trace messages was updated to dump info about
in/out buffers instead of channel buffers when it is relevant.

src/applet.c

index 81bb99964df2bee6df8cc1dc2868ed87844c6461..d93e37a40fb2330689d3f98191e4ee74f8e38acd 100644 (file)
@@ -176,21 +176,41 @@ static void applet_trace(enum trace_level level, uint64_t mask, const struct tra
            (src->verbosity == STRM_VERB_ADVANCED && src->level < TRACE_LEVEL_DATA))
                return;
 
-       /* channels' buffer info */
-       if (s->flags & SF_HTX) {
-               struct htx *ichtx = htxbuf(&ic->buf);
-               struct htx *ochtx = htxbuf(&oc->buf);
-
-               chunk_appendf(&trace_buf, " htx=(%u/%u#%u, %u/%u#%u)",
-                             ichtx->data, ichtx->size, htx_nbblks(ichtx),
-                             ochtx->data, ochtx->size, htx_nbblks(ochtx));
+       if (appctx->t->process == task_run_applet) {
+               /* channels' buffer info */
+               if (s->flags & SF_HTX) {
+                       struct htx *ichtx = htxbuf(&ic->buf);
+                       struct htx *ochtx = htxbuf(&oc->buf);
+
+                       chunk_appendf(&trace_buf, " htx=(%u/%u#%u, %u/%u#%u)",
+                                     ichtx->data, ichtx->size, htx_nbblks(ichtx),
+                                     ochtx->data, ochtx->size, htx_nbblks(ochtx));
+               }
+               else {
+                       chunk_appendf(&trace_buf, " buf=(%u@%p+%u/%u, %u@%p+%u/%u)",
+                                     (unsigned int)b_data(&ic->buf), b_orig(&ic->buf),
+                                     (unsigned int)b_head_ofs(&ic->buf), (unsigned int)b_size(&ic->buf),
+                                     (unsigned int)b_data(&oc->buf), b_orig(&oc->buf),
+                                     (unsigned int)b_head_ofs(&oc->buf), (unsigned int)b_size(&oc->buf));
+               }
        }
        else {
-               chunk_appendf(&trace_buf, " buf=(%u@%p+%u/%u, %u@%p+%u/%u)",
-                             (unsigned int)b_data(&ic->buf), b_orig(&ic->buf),
-                             (unsigned int)b_head_ofs(&ic->buf), (unsigned int)b_size(&ic->buf),
-                             (unsigned int)b_data(&oc->buf), b_orig(&oc->buf),
-                             (unsigned int)b_head_ofs(&oc->buf), (unsigned int)b_size(&oc->buf));
+               /* RX/TX buffer info */
+               if (s->flags & SF_HTX) {
+                       struct htx *rxhtx = htxbuf(&appctx->inbuf);
+                       struct htx *txhtx = htxbuf(&appctx->outbuf);
+
+                       chunk_appendf(&trace_buf, " htx=(%u/%u#%u, %u/%u#%u)",
+                                     rxhtx->data, rxhtx->size, htx_nbblks(rxhtx),
+                                     txhtx->data, txhtx->size, htx_nbblks(txhtx));
+               }
+               else {
+                       chunk_appendf(&trace_buf, " buf=(%u@%p+%u/%u, %u@%p+%u/%u)",
+                                     (unsigned int)b_data(&appctx->inbuf), b_orig(&appctx->inbuf),
+                                     (unsigned int)b_head_ofs(&appctx->inbuf), (unsigned int)b_size(&appctx->inbuf),
+                                     (unsigned int)b_data(&appctx->outbuf), b_orig(&appctx->outbuf),
+                                     (unsigned int)b_head_ofs(&appctx->outbuf), (unsigned int)b_size(&appctx->outbuf));
+               }
        }
 }