mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 14:51:27 +02:00
Main lua lock is used at various places in the code. Most of the time it is used from unprotected lua environments, in which case the locking is mandatory. But there are some cases where the lock is attempted from protected lua environments, meaning that lock is already owned by the current thread. Thus new locking attempt should be skipped to prevent any deadlocks from occuring. To address this, "already_safe" lock hint was implemented in hlua_ctx_init() function with commit bf90ce1 ("BUG/MEDIUM: lua: dead lock when Lua tasks are trigerred") But this approach is not very safe, for 2 reasons: First reason is that there are still some code paths that could lead to deadlocks. For instance, in register_task(), hlua_ctx_init() is called with already_safe set to 1 to prevent deadlock from occuring. But in case of task init failure, hlua_ctx_destroy() will be called from the same environment (protected environment), and hlua_ctx_destroy() does not offer the already_safe lock hint.. resulting in a deadlock. Second reason is that already_safe hint is used to completely skip SET_LJMP macros (which manipulates the lock internally), resulting in some logics in the function being unprotected from lua aborts in case of unexpected errors when manipulating the lua stack (the lock does not protect against longjmps) Instead of leaving the locking responsibility to the caller, which is quite error prone since we must find out ourselves if we are or not in a protected environment (and is not robust against code re-use), we move the deadlock protection logic directly in hlua_lock() function. Thanks to a thread-local lock hint, we can easily guess if the current thread already owns the main lua lock, in which case the locking attempt is skipped. The thread-local lock hint is implemented as a counter so that the lock is properly dropped when the counter reaches 0. (to match actual lock() and unlock() calls) This commit depends on "MINOR: hlua: simplify lua locking" It may be backported to every stable versions. [prior to 2.5 lua filter API did not exist, filter-related parts should be skipped]
The HAProxy documentation has been split into a number of different files for ease of use. Please refer to the following files depending on what you're looking for : - INSTALL for instructions on how to build and install HAProxy - BRANCHES to understand the project's life cycle and what version to use - LICENSE for the project's license - CONTRIBUTING for the process to follow to submit contributions The more detailed documentation is located into the doc/ directory : - doc/intro.txt for a quick introduction on HAProxy - doc/configuration.txt for the configuration's reference manual - doc/lua.txt for the Lua's reference manual - doc/SPOE.txt for how to use the SPOE engine - doc/network-namespaces.txt for how to use network namespaces under Linux - doc/management.txt for the management guide - doc/regression-testing.txt for how to use the regression testing suite - doc/peers.txt for the peers protocol reference - doc/coding-style.txt for how to adopt HAProxy's coding style - doc/internals for developer-specific documentation (not all up to date)
Description
Languages
C
98.1%
Shell
0.8%
Makefile
0.5%
Lua
0.2%
Python
0.2%