MINOR: log: remove the unused curr_idx in struct smp_log_range

This index is useless because it only serves to know when the global
index reached the end, while the global one already knows it. Let's
just drop it and perform the test on the global range.

It was verified with the following config that the first server continues
to take 1/10 of the traffic, the 2nd one 2/10, the 3rd one 3/10 and the
4th one 4/10:

    log 127.0.0.1:10001 sample 1:10 local0
    log 127.0.0.1:10002 sample 2,5:10 local0
    log 127.0.0.1:10003 sample 3,7,9:10 local0
    log 127.0.0.1:10004 sample 4,6,8,10:10 local0
This commit is contained in:
Willy Tarreau 2023-09-20 20:09:58 +02:00
parent 4351364700
commit 3f1284560f
2 changed files with 1 additions and 6 deletions

View File

@ -208,9 +208,6 @@ struct smp_log_range {
size_t sz; /* The size of this range, or number of indexes in
* this range.
*/
unsigned int curr_idx; /* The current index used to sample this range of
*indexes.
*/
};
/* Log sampling information. */

View File

@ -970,7 +970,6 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, const char *file
smp_rgs[smp_rgs_sz].low = low;
smp_rgs[smp_rgs_sz].high = high;
smp_rgs[smp_rgs_sz].sz = high - low + 1;
smp_rgs[smp_rgs_sz].curr_idx = 0;
if (smp_rgs[smp_rgs_sz].high > smp_sz)
smp_sz = smp_rgs[smp_rgs_sz].high;
smp_rgs_sz++;
@ -1841,8 +1840,7 @@ void process_send_log(struct list *logsrvs, int level, int facility,
in_range = curr_rg->low <= next_idx && next_idx <= curr_rg->high;
if (in_range) {
/* Let's consume this range. */
curr_rg->curr_idx = (curr_rg->curr_idx + 1) % curr_rg->sz;
if (!curr_rg->curr_idx) {
if (next_idx == curr_rg->high) {
/* If consumed, let's select the next range. */
logsrv->lb.curr_rg = (logsrv->lb.curr_rg + 1) % logsrv->lb.smp_rgs_sz;
}