]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: xref: Add missing barriers.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 18 Jan 2019 16:21:32 +0000 (17:21 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 31 Jan 2019 18:38:25 +0000 (19:38 +0100)
Add a few missing barriers in the xref code, it's unlikely to be a problem
for x86, but may be on architectures with weak memory ordering.

include/common/xref.h

index 6dfa7b62758dfaebe12d25f66aaa858dc873a060..a6291f52f5badfb53fa0afe2b46b21f53fc6a7d2 100644 (file)
@@ -32,6 +32,7 @@ static inline struct xref *xref_get_peer_and_lock(struct xref *xref)
 
                /* Get the local pointer to the peer. */
                local = HA_ATOMIC_XCHG(&xref->peer, XREF_BUSY);
+               __ha_barrier_store();
 
                /* If the local pointer is NULL, the peer no longer exists. */
                if (local == NULL) {
@@ -53,6 +54,7 @@ static inline struct xref *xref_get_peer_and_lock(struct xref *xref)
                /* The remote lock is BUSY, We retry the process. */
                if (remote == XREF_BUSY) {
                        xref->peer = local;
+                       __ha_barrier_store();
                        continue;
                }
 
@@ -66,6 +68,8 @@ static inline void xref_unlock(struct xref *xref, struct xref *peer)
        /* Release the peer. */
        peer->peer = xref;
 
+       __ha_barrier_store();
+
        /* Release myself. */
        xref->peer = peer;
 }
@@ -73,6 +77,7 @@ static inline void xref_unlock(struct xref *xref, struct xref *peer)
 static inline void xref_disconnect(struct xref *xref, struct xref *peer)
 {
        peer->peer = NULL;
+       __ha_barrier_store();
        xref->peer = NULL;
 }