]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: sample: also report contexts registered directly
authorWilly Tarreau <w@1wt.eu>
Fri, 6 Mar 2026 09:59:18 +0000 (10:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 12 Mar 2026 17:06:38 +0000 (18:06 +0100)
With the two new context types TH_EX_CTX_SMPF/CONV, we can now also
report contexts corresponding to direct calls to sample_register_fetches()
and sample_register_convs(). In this case, the first word of the keyword
list is reported.

include/haproxy/tinfo-t.h
src/sample.c
src/tools.c

index 6cd06d9834646c881e5263ae87f3588eee78ab7e..5dce743835fe89265f4a383398ce0c130956f144 100644 (file)
@@ -81,6 +81,8 @@ enum thread_exec_ctx_type {
        TH_EX_CTX_OTHER,                    /* context only known by a generic pointer */
        TH_EX_CTX_INITCALL,                 /* the pointer is an initcall providing file:line */
        TH_EX_CTX_CALLER,                   /* the pointer is an ha_caller of the caller providing file:line etc */
+       TH_EX_CTX_SMPF,                     /* directly registered sample fetch function, using .smpf_kwl */
+       TH_EX_CTX_CONV,                     /* directly registered converter function, using .conv_kwl */
 };
 
 struct thread_exec_ctx {
@@ -90,6 +92,8 @@ struct thread_exec_ctx {
                const void *pointer;        /* generic pointer (for other) */
                const struct initcall *initcall;  /* used with TH_EX_CTX_INITCALL */
                const struct ha_caller *ha_caller;  /* used with TH_EX_CTX_CALLER */
+               const struct sample_fetch_kw_list *smpf_kwl; /* used with TH_EX_CTX_SMPF */
+               const struct sample_conv_kw_list *conv_kwl;  /* used with TH_EX_CTX_CONV */
        };
 };
 
index 4a79285957eba29b59ce8761af914e22c984824b..42f211ad4af653f5bffb820026f32477142cf8d9 100644 (file)
@@ -458,6 +458,9 @@ void sample_register_fetches(struct sample_fetch_kw_list *kwl)
                if (caller_initcall) {
                        sf->exec_ctx.type = TH_EX_CTX_INITCALL;
                        sf->exec_ctx.initcall = caller_initcall;
+               } else {
+                       sf->exec_ctx.type = TH_EX_CTX_SMPF;
+                       sf->exec_ctx.smpf_kwl = kwl;
                }
        }
        LIST_APPEND(&sample_fetches.list, &kwl->list);
@@ -479,6 +482,9 @@ void sample_register_convs(struct sample_conv_kw_list *pckl)
                if (caller_initcall) {
                        sc->exec_ctx.type = TH_EX_CTX_INITCALL;
                        sc->exec_ctx.initcall = caller_initcall;
+               } else {
+                       sc->exec_ctx.type = TH_EX_CTX_CONV;
+                       sc->exec_ctx.conv_kwl = pckl;
                }
        }
        LIST_APPEND(&sample_convs.list, &pckl->list);
index 39b43ba2c5712b2ce9ce61bc58d82bff75615037..10a9badca5cfe5309253176220441de0dab8b318 100644 (file)
@@ -7529,6 +7529,12 @@ void chunk_append_thread_ctx(struct buffer *output, const struct thread_exec_ctx
                chunk_appendf(output,"ctx registered at %s@%s:%d", ctx->ha_caller->func, slash, ctx->ha_caller->line);
                break;
        }
+       case TH_EX_CTX_SMPF:
+               chunk_appendf(output,"smpf kwl starting with '%s'", ctx->smpf_kwl->kw[0].kw);
+               break;
+       case TH_EX_CTX_CONV:
+               chunk_appendf(output,"conv kwl starting with '%s'", ctx->conv_kwl->kw[0].kw);
+               break;
        default:
                chunk_appendf(output,"other ctx %p", ctx->pointer);
                break;