]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: memory: fix free_list pointer declaration again for atomic CAS
authorOlivier Houchard <cognet@ci0.org>
Sat, 20 Oct 2018 23:52:59 +0000 (01:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 21 Oct 2018 03:44:38 +0000 (05:44 +0200)
Similary to what's been done in 7a6ad88b02d8b74c2488003afb1a7063043ddd2d,
take into account that free_list that free_list is a void **, and so use
a void ** too when attempting to do a CAS.

src/memory.c

index d75dc7e6e0de3655c3f7ccc02bc7d37b36552ae3..6a345e5569167a8db13ff5923d76fe7f40c3e265 100644 (file)
@@ -137,7 +137,7 @@ struct pool_head *create_pool(char *name, unsigned int size, unsigned int flags)
  */
 void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail)
 {
-       void *ptr = NULL, *free_list;
+       void *ptr = NULL, **free_list;
        int failed = 0;
        int size = pool->size;
        int limit = pool->limit;
@@ -168,7 +168,7 @@ void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail)
                do {
                        *POOL_LINK(pool, ptr) = free_list;
                        __ha_barrier_store();
-               } while (HA_ATOMIC_CAS(&pool->free_list, (void **)&free_list, ptr) == 0);
+               } while (HA_ATOMIC_CAS(&pool->free_list, &free_list, ptr) == 0);
        }
 
        HA_ATOMIC_ADD(&pool->allocated, allocated - allocated_orig);
@@ -192,14 +192,14 @@ void *pool_refill_alloc(struct pool_head *pool, unsigned int avail)
  */
 void pool_flush(struct pool_head *pool)
 {
-       void *next, *temp;
+       void **next, *temp;
        int removed = 0;
 
        if (!pool)
                return;
        do {
                next = pool->free_list;
-       } while (!HA_ATOMIC_CAS(&pool->free_list, (void **)&next, NULL));
+       } while (!HA_ATOMIC_CAS(&pool->free_list, &next, NULL));
        while (next) {
                temp = next;
                next = *POOL_LINK(pool, temp);