mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
MINOR: queue: simplify pendconn_unlink() regarding srv vs px
Since the code paths became exactly the same except for what log field to update, let's simplify the code and move further code out of the lock. The queue position update and the test for server vs proxy do not need to be inside the lock.
This commit is contained in:
parent
51c63f0f0a
commit
d03adce575
46
src/queue.c
46
src/queue.c
@ -172,41 +172,33 @@ static inline void pendconn_queue_unlock(struct pendconn *p)
|
|||||||
* connection is not really dequeued. It will be done during process_stream().
|
* connection is not really dequeued. It will be done during process_stream().
|
||||||
* This function takes all the required locks for the operation. The pendconn
|
* This function takes all the required locks for the operation. The pendconn
|
||||||
* must be valid, though it doesn't matter if it was already unlinked. Prefer
|
* must be valid, though it doesn't matter if it was already unlinked. Prefer
|
||||||
* pendconn_cond_unlink() to first check <p>. When the locks are already held,
|
* pendconn_cond_unlink() to first check <p>.
|
||||||
* please use __pendconn_unlink_{srv,prx}() instead.
|
|
||||||
*/
|
*/
|
||||||
void pendconn_unlink(struct pendconn *p)
|
void pendconn_unlink(struct pendconn *p)
|
||||||
{
|
{
|
||||||
int done = 0;
|
|
||||||
struct queue *q = p->queue;
|
struct queue *q = p->queue;
|
||||||
struct proxy *px = q->px;
|
struct proxy *px = q->px;
|
||||||
struct server *sv = q->sv;
|
struct server *sv = q->sv;
|
||||||
|
uint oldidx;
|
||||||
|
int done = 0;
|
||||||
|
|
||||||
if (sv) {
|
oldidx = _HA_ATOMIC_LOAD(&p->queue->idx);
|
||||||
/* queued in the server */
|
HA_SPIN_LOCK(QUEUE_LOCK, &q->lock);
|
||||||
HA_SPIN_LOCK(QUEUE_LOCK, &q->lock);
|
if (p->node.node.leaf_p) {
|
||||||
if (p->node.node.leaf_p) {
|
eb32_delete(&p->node);
|
||||||
__pendconn_unlink_srv(p);
|
done = 1;
|
||||||
done = 1;
|
|
||||||
}
|
|
||||||
HA_SPIN_UNLOCK(QUEUE_LOCK, &q->lock);
|
|
||||||
if (done) {
|
|
||||||
_HA_ATOMIC_DEC(&q->length);
|
|
||||||
_HA_ATOMIC_DEC(&px->totpend);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
HA_SPIN_UNLOCK(QUEUE_LOCK, &q->lock);
|
||||||
/* queued in the proxy */
|
|
||||||
HA_SPIN_LOCK(QUEUE_LOCK, &q->lock);
|
if (done) {
|
||||||
if (p->node.node.leaf_p) {
|
oldidx -= p->queue_idx;
|
||||||
__pendconn_unlink_prx(p);
|
if (sv)
|
||||||
done = 1;
|
p->strm->logs.srv_queue_pos += oldidx;
|
||||||
}
|
else
|
||||||
HA_SPIN_UNLOCK(QUEUE_LOCK, &q->lock);
|
p->strm->logs.prx_queue_pos += oldidx;
|
||||||
if (done) {
|
|
||||||
_HA_ATOMIC_DEC(&q->length);
|
_HA_ATOMIC_DEC(&q->length);
|
||||||
_HA_ATOMIC_DEC(&px->totpend);
|
_HA_ATOMIC_DEC(&px->totpend);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user