MEDIUM: lb/threads: Use the new _HA_ATOMIC_* macros.
Use the new _HA_ATOMIC_* macros and add barriers where needed.
diff --git a/src/lb_fwrr.c b/src/lb_fwrr.c
index 3532279..9a2ebe1 100644
--- a/src/lb_fwrr.c
+++ b/src/lb_fwrr.c
@@ -354,7 +354,7 @@
s->npos >= grp->curr_weight + grp->next_weight) {
/* put into next tree, and readjust npos in case we could
* finally take this back to current. */
- HA_ATOMIC_SUB(&s->npos, grp->curr_weight);
+ _HA_ATOMIC_SUB(&s->npos, grp->curr_weight);
fwrr_queue_by_weight(grp->next, s);
}
else {
@@ -392,7 +392,7 @@
&s->proxy->lbprm.fwrr.bck :
&s->proxy->lbprm.fwrr.act;
- HA_ATOMIC_ADD(&s->npos, grp->curr_weight);
+ _HA_ATOMIC_ADD(&s->npos, grp->curr_weight);
}
/* prepares a server when it was marked down.
@@ -487,20 +487,20 @@
/* first time ever for this server */
s->lpos = grp->curr_pos;
s->npos = grp->curr_pos + grp->next_weight / s->cur_eweight;
- HA_ATOMIC_ADD(&s->rweight, (grp->next_weight % s->cur_eweight));
+ _HA_ATOMIC_ADD(&s->rweight, (grp->next_weight % s->cur_eweight));
if (s->rweight >= s->cur_eweight) {
- HA_ATOMIC_SUB(&s->rweight, s->cur_eweight);
- HA_ATOMIC_ADD(&s->npos, 1);
+ _HA_ATOMIC_SUB(&s->rweight, s->cur_eweight);
+ _HA_ATOMIC_ADD(&s->npos, 1);
}
} else {
s->lpos = s->npos;
- HA_ATOMIC_ADD(&s->npos, (grp->next_weight / s->cur_eweight));
- HA_ATOMIC_ADD(&s->rweight, (grp->next_weight % s->cur_eweight));
+ _HA_ATOMIC_ADD(&s->npos, (grp->next_weight / s->cur_eweight));
+ _HA_ATOMIC_ADD(&s->rweight, (grp->next_weight % s->cur_eweight));
if (s->rweight >= s->cur_eweight) {
- HA_ATOMIC_SUB(&s->rweight, s->cur_eweight);
- HA_ATOMIC_ADD(&s->npos, 1);
+ _HA_ATOMIC_SUB(&s->rweight, s->cur_eweight);
+ _HA_ATOMIC_ADD(&s->npos, 1);
}
}
}
diff --git a/src/lb_map.c b/src/lb_map.c
index 4b992d3..245af00 100644
--- a/src/lb_map.c
+++ b/src/lb_map.c
@@ -123,7 +123,7 @@
break;
}
- HA_ATOMIC_ADD(&cur->wscore, cur->next_eweight);
+ _HA_ATOMIC_ADD(&cur->wscore, cur->next_eweight);
v = (cur->wscore + tot) / tot; /* result between 0 and 3 */
if (best == NULL || v > max) {
max = v;
@@ -133,7 +133,7 @@
}
px->lbprm.map.srv[o] = best;
if (best)
- HA_ATOMIC_SUB(&best->wscore, tot);
+ _HA_ATOMIC_SUB(&best->wscore, tot);
}
}