]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: buffers: Fix b_alloc_margin to be "fonctionnaly" thread-safe
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 10 Nov 2017 09:39:16 +0000 (10:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Nov 2017 10:42:48 +0000 (11:42 +0100)
commitfa5c812a6bab78a0c0c53ccfeb9393dd3dcaec80
treefa9880545929148d6daa67b0c8df68cafeb38a4a
parent9dcf9b6f031ed02a05cbbc76bf06b53d97d25fa3
BUG/MINOR: buffers: Fix b_alloc_margin to be "fonctionnaly" thread-safe

b_alloc_margin is, strickly speeking, thread-safe. It will not crash
HAproxy. But its contract is not respected anymore in a multithreaded
environment. In this function, we need to be sure to have <margin> buffers
available in the pool after the allocation. So to have this guarantee, we must
lock the memory pool during all the operation. This also means, we must call
internal and lockless memory functions (prefixed with '__').

For the record, this patch fixes a pernicious bug happens after a soft reload
where some streams can be blocked infinitly, waiting for a buffer in the
buffer_wq list. This happens because, during a soft reload, pool_gc2 is called,
making some calls to b_alloc_fast fail.

This is specific to threads, no backport is needed.
include/common/buffer.h