MINOR: mux-h2: avoid taking the toremove_lock in on dying tasks

If the owning task is already dying (context was destroyed by h2_takeover)
there's no point taking the lock then removing it later since all the code
in between is conditionned by a non-null context. Let's simplify this.
This commit is contained in:
Willy Tarreau 2020-06-30 11:19:23 +02:00
parent 68d4ee9e26
commit bd42e9257d

View File

@ -3705,12 +3705,13 @@ static struct task *h2_timeout_task(struct task *t, void *context, unsigned shor
TRACE_ENTER(H2_EV_H2C_WAKE, h2c ? h2c->conn : NULL); TRACE_ENTER(H2_EV_H2C_WAKE, h2c ? h2c->conn : NULL);
if (!expired && h2c) { if (h2c) {
if (!expired) {
TRACE_DEVEL("leaving (not expired)", H2_EV_H2C_WAKE, h2c->conn); TRACE_DEVEL("leaving (not expired)", H2_EV_H2C_WAKE, h2c->conn);
return t; return t;
} }
if (h2c && !h2c_may_expire(h2c)) { if (!h2c_may_expire(h2c)) {
/* we do still have streams but all of them are idle, waiting /* we do still have streams but all of them are idle, waiting
* for the data layer, so we must not enforce the timeout here. * for the data layer, so we must not enforce the timeout here.
*/ */
@ -3723,7 +3724,7 @@ static struct task *h2_timeout_task(struct task *t, void *context, unsigned shor
*/ */
HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock); HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
if (h2c && h2c->conn->flags & CO_FL_LIST_MASK) if (h2c->conn->flags & CO_FL_LIST_MASK)
MT_LIST_DEL(&h2c->conn->list); MT_LIST_DEL(&h2c->conn->list);
/* Somebody already stole the connection from us, so we should not /* Somebody already stole the connection from us, so we should not
@ -3733,6 +3734,7 @@ static struct task *h2_timeout_task(struct task *t, void *context, unsigned shor
h2c = NULL; h2c = NULL;
HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock); HA_SPIN_UNLOCK(OTHER_LOCK, &idle_conns[tid].toremove_lock);
}
task_destroy(t); task_destroy(t);