From 9f68049cc12846d844d16c05629832e17ecf67a6 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Wed, 15 Jan 2025 21:14:48 +0100 Subject: [PATCH] CLEANUP: stktable: move sample_conv_table_bytes_out_rate() sample_conv_table_bytes_out_rate() was defined in the middle of other stick-table sample convs without any ordering logic. Let's put it where it belongs, right after sample_conv_table_bytes_in_rate(). --- src/stick_table.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/stick_table.c b/src/stick_table.c index 365c9e0b6..dd23b52d6 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -1825,6 +1825,23 @@ static int sample_conv_table_bytes_in_rate(const struct arg *arg_p, struct sampl return smp_fetch_bytes_in_rate(&stkctr, smp, 1); } +/* Casts sample to the type of the table specified in arg(0), and looks + * it up into this table. Returns the data rate sent to clients in bytes/s + * if the key is present in the table, otherwise zero, so that comparisons can + * be easily performed. If the inspected parameter is not stored in the table, + * is returned. + */ +static int smp_fetch_bytes_out_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt); +static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct sample *smp, void *private) +{ + struct stkctr stkctr; + + stkctr.table = arg_p[0].data.t; + stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0)); + + return smp_fetch_bytes_out_rate(&stkctr, smp, 1); +} + /* Casts sample to the type of the table specified in arg(0), and looks * it up into this table. Returns the cumulated number of connections for the key * if the key is present in the table, otherwise zero, so that comparisons can @@ -1942,23 +1959,6 @@ static int sample_conv_table_idle(const struct arg *arg_p, struct sample *smp, v return 1; } -/* Casts sample to the type of the table specified in arg(0), and looks - * it up into this table. Returns the data rate sent to clients in bytes/s - * if the key is present in the table, otherwise zero, so that comparisons can - * be easily performed. If the inspected parameter is not stored in the table, - * is returned. - */ -static int smp_fetch_bytes_out_rate(struct stkctr *stkctr, struct sample *smp, int decrefcnt); -static int sample_conv_table_bytes_out_rate(const struct arg *arg_p, struct sample *smp, void *private) -{ - struct stkctr stkctr; - - stkctr.table = arg_p[0].data.t; - stkctr_set_entry(&stkctr, smp_fetch_stksess(stkctr.table, smp, 0)); - - return smp_fetch_bytes_out_rate(&stkctr, smp, 1); -} - /* Casts sample to the type of the table specified in arg(0), and looks * it up into this table. Returns the cumulated number of front glitches for the * key if the key is present in the table, otherwise zero, so that comparisons