Revert "MEDIUM: queue: refine the locking in process_srv_queue()"

This reverts commit 1b648c857b.

The recent changes since 5304669e1 MEDIUM: queue: make
pendconn_process_next_strm() only return the pendconn opened a tiny race
condition between stream_free() and process_srv_queue(), as the pendconn
is accessed outside of the lock, possibly while it's being freed. A
different approach is required.
This commit is contained in:
Willy Tarreau 2021-06-24 07:26:57 +02:00
parent 3f70fb9ea2
commit e76fc3253d

View File

@ -340,29 +340,27 @@ void process_srv_queue(struct server *s, int server_locked)
int done = 0;
int maxconn;
if (!server_locked)
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
HA_RWLOCK_WRLOCK(PROXY_LOCK, &p->lock);
maxconn = srv_dynamic_maxconn(s);
while (s->served < maxconn) {
struct pendconn *pc;
if (!server_locked)
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
HA_RWLOCK_WRLOCK(PROXY_LOCK, &p->lock);
pc = pendconn_process_next_strm(s, p);
HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &p->lock);
if (!server_locked)
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
if (!pc)
break;
done++;
_HA_ATOMIC_INC(&s->served);
stream_add_srv_conn(pc->strm, s);
task_wakeup(pc->strm->task, TASK_WOKEN_RES);
}
HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &p->lock);
if (!server_locked)
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
_HA_ATOMIC_ADD(&p->served, done);