mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-01 11:01:46 +00:00
MINOR: queue: reduce the locked area in pendconn_add()
Similarly to previous changes, we know if we're dealing with a server or proxy lock so let's directly lock at the finest possible places there. It's worth noting that a part of the operation consisting in an increment and update of a max could be done outside of the lock using atomic ops and a CAS.
This commit is contained in:
parent
3e3ae2524d
commit
c7eedf7a5a
@ -383,26 +383,26 @@ struct pendconn *pendconn_add(struct stream *strm)
|
||||
p->strm = strm;
|
||||
p->strm_flags = strm->flags;
|
||||
|
||||
pendconn_queue_lock(p);
|
||||
|
||||
if (srv) {
|
||||
HA_SPIN_LOCK(SERVER_LOCK, &p->srv->lock);
|
||||
srv->nbpend++;
|
||||
if (srv->nbpend > srv->counters.nbpend_max)
|
||||
srv->counters.nbpend_max = srv->nbpend;
|
||||
p->queue_idx = srv->queue_idx - 1; // for increment
|
||||
eb32_insert(&srv->pendconns, &p->node);
|
||||
HA_SPIN_UNLOCK(SERVER_LOCK, &p->srv->lock);
|
||||
}
|
||||
else {
|
||||
HA_RWLOCK_WRLOCK(PROXY_LOCK, &p->px->lock);
|
||||
px->nbpend++;
|
||||
if (px->nbpend > px->be_counters.nbpend_max)
|
||||
px->be_counters.nbpend_max = px->nbpend;
|
||||
p->queue_idx = px->queue_idx - 1; // for increment
|
||||
eb32_insert(&px->pendconns, &p->node);
|
||||
HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &p->px->lock);
|
||||
}
|
||||
strm->pend_pos = p;
|
||||
|
||||
pendconn_queue_unlock(p);
|
||||
|
||||
_HA_ATOMIC_ADD(&px->totpend, 1);
|
||||
return p;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user