MEDIUM: threads/lua: Add locks around the Lua execution parts.
authorThierry FOURNIER <thierry.fournier@ozon.io>
Wed, 12 Jul 2017 09:41:21 +0000 (11:41 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 12:58:32 +0000 (13:58 +0100)
commit61ba0e2b6d073126a857f71e01068ef319f8dfb4
treee953e428df769f4fc928aa09bec15598f8d2eeee
parentffbad790276486fe16326571d9d406e4188aebdf
MEDIUM: threads/lua: Add locks around the Lua execution parts.

Note that the Lua processing is not really thread safe. It provides
heavy system which consists to add our own lock function in the Lua
code and recompile the library. This system will probably not accepted
by maintainers of various distribs.

Our main excution point of the Lua is the function lua_resume(). A
quick looking on the Lua sources displays a lua_lock() a the start
of function and a lua_unlock() at the end of the function. So I
conclude that the Lua thread safe mode just perform a mutex around
all execution. So I prefer to do this in the HAProxy code, it will be
easier for distro maintainers.

Note that the HAProxy lua functions rounded by the macro SET_SAFE_LJMP
and RESET_SAFE_LJMP manipulates the Lua stack, so it will be careful
to set mutex around these functions.
include/common/hathreads.h
src/hlua.c