diff --git a/include/haproxy/log.h b/include/haproxy/log.h index 4c7b455ea..16cc67150 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -155,17 +155,6 @@ char *update_log_hdr(const time_t time); char * get_format_pid_sep1(int format, size_t *len); char * get_format_pid_sep2(int format, size_t *len); -/* - * Test if index numbered from 0 is in range with low and high - * limits of indexes numbered from 1. - */ -static inline int in_smp_log_range(struct smp_log_range *rg, unsigned int idx) -{ - if (idx + 1 <= rg->high && idx + 1 >= rg->low) - return 1; - return 0; -} - /* * Builds a log line for the stream (must be valid). */ diff --git a/src/log.c b/src/log.c index b899ad511..3d9e39041 100644 --- a/src/log.c +++ b/src/log.c @@ -1831,10 +1831,14 @@ void process_send_log(struct list *logsrvs, int level, int facility, if (logsrv->lb.smp_rgs) { struct smp_log_range *curr_rg; + unsigned int next_idx; HA_SPIN_LOCK(LOGSRV_LOCK, &logsrv->lock); + next_idx = logsrv->lb.curr_idx + 1; curr_rg = &logsrv->lb.smp_rgs[logsrv->lb.curr_rg]; - in_range = in_smp_log_range(curr_rg, logsrv->lb.curr_idx); + + /* check if the index we're going to take is within range */ + 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; @@ -1843,7 +1847,7 @@ void process_send_log(struct list *logsrvs, int level, int facility, logsrv->lb.curr_rg = (logsrv->lb.curr_rg + 1) % logsrv->lb.smp_rgs_sz; } } - logsrv->lb.curr_idx = (logsrv->lb.curr_idx + 1) % logsrv->lb.smp_sz; + logsrv->lb.curr_idx = next_idx % logsrv->lb.smp_sz; HA_SPIN_UNLOCK(LOGSRV_LOCK, &logsrv->lock); } if (in_range)