mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 20:46:11 +02:00
MINOR: sample: return the number of the current thread group
Just like we have a sample fetch function that returns the number of the current thread, let's have the same with the thread group number. This can be useful for troubleshooting, given that certain things are currently per thread-group (e.g. idle backend connections, certain LB algos etc).
This commit is contained in:
parent
b943d2a7eb
commit
630ef96f92
@ -24019,6 +24019,11 @@ term_events : string
|
||||
It must only be used for debugging purpose. The exact format is not
|
||||
documented because it may evolve depending on developers requirements.
|
||||
|
||||
tgroup : integer
|
||||
Returns an integer value corresponding to the position of the thread group
|
||||
calling the function, between 0 and (global.thread-groups - 1). This is
|
||||
useful for logging and debugging purposes.
|
||||
|
||||
thread : integer
|
||||
Returns an integer value corresponding to the position of the thread calling
|
||||
the function, between 0 and (global.nbthread-1). This is useful for logging
|
||||
|
||||
10
src/sample.c
10
src/sample.c
@ -5080,6 +5080,15 @@ smp_fetch_thread(const struct arg *args, struct sample *smp, const char *kw, voi
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* returns the number of the current thread group (between 0 and nbtgroups-1) */
|
||||
static int
|
||||
smp_fetch_tgroup(const struct arg *args, struct sample *smp, const char *kw, void *private)
|
||||
{
|
||||
smp->data.type = SMP_T_SINT;
|
||||
smp->data.u.sint = tgid - 1; // tgid starts at 1
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* generate a random 32-bit integer for whatever purpose, with an optional
|
||||
* range specified in argument.
|
||||
*/
|
||||
@ -5659,6 +5668,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
|
||||
{ "proc", smp_fetch_proc, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "quic_enabled", smp_fetch_quic_enabled, 0, NULL, SMP_T_BOOL, SMP_USE_CONST },
|
||||
{ "thread", smp_fetch_thread, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "tgroup", smp_fetch_tgroup, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "rand", smp_fetch_rand, ARG1(0,SINT), NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
{ "stopping", smp_fetch_stopping, 0, NULL, SMP_T_BOOL, SMP_USE_INTRN },
|
||||
{ "uptime", smp_fetch_uptime, 0, NULL, SMP_T_SINT, SMP_USE_CONST },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user