]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: hlua_fcn/queue: use atomic load to fetch queue size
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Jul 2023 13:42:00 +0000 (15:42 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Jul 2023 14:04:39 +0000 (16:04 +0200)
In hlua_queue_size(), queue size is loaded as a regular int, but the
queue might be shared by multiple threads that could perform some
atomic pushing or popping attempts in parallel, so we better use an
atomic load operation to guarantee consistent readings.

This could be backported in 2.8.

src/hlua_fcn.c

index 91c5155d22bdb7a001e48fcf72d911c2f61ce651..63366694fd125676b87522ff9bb89791a06f03b9 100644 (file)
@@ -542,7 +542,7 @@ static int hlua_queue_size(lua_State *L)
        struct hlua_queue *queue = hlua_check_queue(L, 1);
 
        BUG_ON(!queue);
-       lua_pushinteger(L, queue->size);
+       lua_pushinteger(L, HA_ATOMIC_LOAD(&queue->size));
 
        return 1;
 }