]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: queue: update the stream's pend_pos before queuing it
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Jun 2021 08:33:47 +0000 (10:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Jun 2021 16:21:18 +0000 (18:21 +0200)
Since commit c7eedf7a5 ("MINOR: queue: reduce the locked area in
pendconn_add()") the stream's pend_pos is set out of the lock, after
the pendconn is queued. While this entry is only manipulated by the
stream itself and there is no bug caused by this right now, it's a
bit dangerous because another thread could decide to look at this
field during dequeuing and could randomly see something else. Also
in case of crashes, memory inspection wouldn't be as trustable.
Let's assign the pendconn before it can be found in the queue.

src/queue.c

index 6ff3404413890ac5db068b808080683f80f20111..6c51dcd2905359d715e8a253f7503b2b9d3b26e5 100644 (file)
@@ -397,6 +397,7 @@ struct pendconn *pendconn_add(struct stream *strm)
        p->px         = px;
        p->strm       = strm;
        p->strm_flags = strm->flags;
+       strm->pend_pos = p;
 
        if (srv) {
                unsigned int old_max, new_max;
@@ -430,7 +431,6 @@ struct pendconn *pendconn_add(struct stream *strm)
                eb32_insert(&px->pendconns, &p->node);
                HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &p->px->lock);
        }
-       strm->pend_pos = p;
 
        _HA_ATOMIC_INC(&px->totpend);
        return p;