]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "MINOR: queue: update proxy->served once out of the loop"
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Jun 2021 05:26:59 +0000 (07:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Jun 2021 07:55:14 +0000 (09:55 +0200)
This reverts commit 3e92a31783b545dd58c4be6c588808763e0042bc.

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.

src/queue.c

index d8e73b2181d9c562ed4e73e315e96a328517c219..60b16a0661366f7fb762f5c45513d66d708000af 100644 (file)
@@ -351,9 +351,10 @@ void process_srv_queue(struct server *s, int server_locked)
                if (!pc)
                        break;
 
-               done++;
+               done = 1;
 
                _HA_ATOMIC_INC(&s->served);
+               _HA_ATOMIC_INC(&p->served);
 
                stream_add_srv_conn(pc->strm, s);
                task_wakeup(pc->strm->task, TASK_WOKEN_RES);
@@ -362,8 +363,6 @@ void process_srv_queue(struct server *s, int server_locked)
        if (!server_locked)
                HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
 
-       _HA_ATOMIC_ADD(&p->served, done);
-
        if (done && p->lbprm.server_take_conn)
                p->lbprm.server_take_conn(s);
 }