diff --git a/src/lb_map.c b/src/lb_map.c index 143291331..b735678a8 100644 --- a/src/lb_map.c +++ b/src/lb_map.c @@ -216,7 +216,7 @@ struct server *map_get_server_rr(struct proxy *px, struct server *srvtoavoid) int newidx, avoididx; struct server *srv, *avoided; - HA_RWLOCK_WRLOCK(LBPRM_LOCK, &px->lbprm.lock); + HA_RWLOCK_SKLOCK(LBPRM_LOCK, &px->lbprm.lock); if (px->lbprm.tot_weight == 0) { avoided = NULL; goto out; @@ -248,7 +248,7 @@ struct server *map_get_server_rr(struct proxy *px, struct server *srvtoavoid) px->lbprm.map.rr_idx = avoididx; out: - HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &px->lbprm.lock); + HA_RWLOCK_SKUNLOCK(LBPRM_LOCK, &px->lbprm.lock); /* return NULL or srvtoavoid if found */ return avoided; } @@ -265,10 +265,10 @@ struct server *map_get_server_hash(struct proxy *px, unsigned int hash) { struct server *srv = NULL; - HA_RWLOCK_WRLOCK(LBPRM_LOCK, &px->lbprm.lock); + HA_RWLOCK_RDLOCK(LBPRM_LOCK, &px->lbprm.lock); if (px->lbprm.tot_weight) srv = px->lbprm.map.srv[hash % px->lbprm.tot_weight]; - HA_RWLOCK_WRUNLOCK(LBPRM_LOCK, &px->lbprm.lock); + HA_RWLOCK_RDUNLOCK(LBPRM_LOCK, &px->lbprm.lock); return srv; }