*/
static inline void health_adjust(struct server *s, short status)
{
- HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
/* return now if observing nor health check is not enabled */
- if (!s->observe || !s->check.task) {
- HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
+ if (!s->observe || !s->check.task)
return;
- }
__health_adjust(s, status);
- HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
}
#endif /* _HAPROXY_CHECKS_H */
}
/* note: use health_adjust() only, which first checks that the observe mode is
- * enabled.
+ * enabled. This will take the server lock if needed.
*/
void __health_adjust(struct server *s, short status)
{
chunk_printf(&trash, "Detected %d consecutive errors, last one was: %s",
s->consecutive_errors, get_analyze_status(status));
+ if (s->check.fastinter)
+ expire = tick_add(now_ms, MS_TO_TICKS(s->check.fastinter));
+ else
+ expire = TICK_ETERNITY;
+
+ HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
+
switch (s->onerror) {
case HANA_ONERR_FASTINTER:
/* force fastinter - nothing to do here as all modes force it */
break;
}
+ HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
+
s->consecutive_errors = 0;
_HA_ATOMIC_ADD(&s->counters.failed_hana, 1);
- if (s->check.fastinter) {
- expire = tick_add(now_ms, MS_TO_TICKS(s->check.fastinter));
- if (tick_is_lt(expire, s->check.task->expire)) {
- s->check.task->expire = expire;
- /* requeue check task with new expire */
- task_queue(s->check.task);
- }
+ if (tick_is_lt(expire, s->check.task->expire)) {
+ /* requeue check task with new expire */
+ task_schedule(s->check.task, expire);
}
}