BUG/MINOR: vars: Fix the set-var and unset-var converters
In commit 3a4bedccc6 the variable logic was changed. Instead of
accessing variables by their name during runtime, the variable tables
are now indexed by a hash of the name. But the set-var and unset-var
converters try to access the correct variable by calculating a hash on
the sample instead of the already calculated variable hash.
It should be backported to 2.5.
diff --git a/src/vars.c b/src/vars.c
index a61fb12..f96bb27 100644
--- a/src/vars.c
+++ b/src/vars.c
@@ -460,19 +460,13 @@
/* Returns 0 if fails, else returns 1. */
static int smp_conv_store(const struct arg *args, struct sample *smp, void *private)
{
- uint64_t seed = var_name_hash_seed;
- uint64_t name_hash = XXH3(smp->data.u.str.area, smp->data.u.str.data, seed);
-
- return var_set(name_hash, args[0].data.var.scope, smp, 0);
+ return var_set(args[0].data.var.name_hash, args[0].data.var.scope, smp, 0);
}
/* Returns 0 if fails, else returns 1. */
static int smp_conv_clear(const struct arg *args, struct sample *smp, void *private)
{
- uint64_t seed = var_name_hash_seed;
- uint64_t name_hash = XXH3(smp->data.u.str.area, smp->data.u.str.data, seed);
-
- return var_unset(name_hash, args[0].data.var.scope, smp);
+ return var_unset(args[0].data.var.name_hash, args[0].data.var.scope, smp);
}
/* This functions check an argument entry and fill it with a variable