MINOR: fd: implement an exclusive syscall bit to remove the ugly "log" lock
authorWilly Tarreau <w@1wt.eu>
Wed, 7 Apr 2021 15:36:57 +0000 (17:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Apr 2021 16:18:37 +0000 (18:18 +0200)
commit1673c4a8837b7e90a221c248669942f6f3988211
tree7c298e7962e1f31e787b58a3dde43529cb909e25
parent9063a660cc743d3cff76e23c9632522518c49227
MINOR: fd: implement an exclusive syscall bit to remove the ugly "log" lock

There is a function called fd_write_frag_line() that's essentially used
by loggers and that is used to write an atomic message line over a file
descriptor using writev(). However a lock is required around the writev()
call to prevent messages from multiple threads from being interleaved.
Till now a SPIN_TRYLOCK was used on a dedicated lock that was common to
all FDs. This is quite not pretty as if there are multiple output pipes
to collect logs, there will be quite some contention. Now that there
are empty flags left in the FD state and that we can finally use atomic
ops on them, let's add a flag to indicate the FD is locked for exclusive
access by a syscall. At least the locking will now be on an FD basis and
not the whole process, so we can remove the log_lock.
include/haproxy/fd-t.h
src/fd.c