mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
MINOR: check: use atomic for s->consecutive_errors
Properly use atomic operations when dealing with s->consecutive_errors as we're using it out of server's lock. Race is negligible, no backport needed.
This commit is contained in:
parent
7d541a91ec
commit
81b7c9518c
12
src/check.c
12
src/check.c
@ -511,7 +511,7 @@ void set_server_check_status(struct check *check, short status, const char *desc
|
|||||||
|
|
||||||
/* clear consecutive_errors if observing is enabled */
|
/* clear consecutive_errors if observing is enabled */
|
||||||
if (s->onerror)
|
if (s->onerror)
|
||||||
s->consecutive_errors = 0;
|
HA_ATOMIC_STORE(&s->consecutive_errors, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -656,17 +656,15 @@ void __health_adjust(struct server *s, short status)
|
|||||||
|
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
/* good: clear consecutive_errors */
|
/* good: clear consecutive_errors */
|
||||||
s->consecutive_errors = 0;
|
HA_ATOMIC_STORE(&s->consecutive_errors, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_HA_ATOMIC_INC(&s->consecutive_errors);
|
if (HA_ATOMIC_ADD_FETCH(&s->consecutive_errors, 1) < s->consecutive_errors_limit)
|
||||||
|
|
||||||
if (s->consecutive_errors < s->consecutive_errors_limit)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
chunk_printf(&trash, "Detected %d consecutive errors, last one was: %s",
|
chunk_printf(&trash, "Detected %d consecutive errors, last one was: %s",
|
||||||
s->consecutive_errors, get_analyze_status(status));
|
HA_ATOMIC_LOAD(&s->consecutive_errors), get_analyze_status(status));
|
||||||
|
|
||||||
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
|
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
|
||||||
|
|
||||||
@ -709,7 +707,7 @@ void __health_adjust(struct server *s, short status)
|
|||||||
|
|
||||||
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
|
||||||
|
|
||||||
s->consecutive_errors = 0;
|
HA_ATOMIC_STORE(&s->consecutive_errors, 0);
|
||||||
_HA_ATOMIC_INC(&s->counters.failed_hana);
|
_HA_ATOMIC_INC(&s->counters.failed_hana);
|
||||||
|
|
||||||
if (s->check.fastinter) {
|
if (s->check.fastinter) {
|
||||||
|
Loading…
Reference in New Issue
Block a user