extern THREAD_LOCAL char *logline_rfc5424;
+/*
+ * 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;
+}
+
/* Initialize/Deinitialize log buffers used for syslog messages */
int init_log_buffers();
void deinit_log_buffers();
cur_arg += 2;
}
+ HA_SPIN_INIT(&logsrv->lock);
/* parse the facility */
logsrv->facility = get_log_facility(args[cur_arg]);
if (logsrv->facility < 0) {
/* Send log messages to syslog server. */
nblogger = 0;
list_for_each_entry(logsrv, logsrvs, list) {
+ static THREAD_LOCAL int in_range = 1;
+
/* we can filter the level of the messages that are sent to each logger */
if (level > logsrv->level)
continue;
- __do_send_log(logsrv, ++nblogger, pid.area, pid.data, level,
- message, size, sd, sd_size, tag->area, tag->data);
+ if (logsrv->lb.smp_rgs) {
+ struct smp_log_range *curr_rg;
+
+ HA_SPIN_LOCK(LOGSRV_LOCK, &logsrv->lock);
+ curr_rg = &logsrv->lb.smp_rgs[logsrv->lb.curr_rg];
+ in_range = in_smp_log_range(curr_rg, logsrv->lb.curr_idx);
+ 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 consumed, let's select the next range. */
+ 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;
+ HA_SPIN_UNLOCK(LOGSRV_LOCK, &logsrv->lock);
+ }
+ if (in_range)
+ __do_send_log(logsrv, ++nblogger, pid.area, pid.data, level,
+ message, size, sd, sd_size, tag->area, tag->data);
}
}