char * get_format_pid_sep1(int format, size_t *len);
char * get_format_pid_sep2(int format, size_t *len);
-/*
- * Test if <idx> index numbered from 0 is in <rg> 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).
*/
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;
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)