From: Thierry FOURNIER Date: Wed, 12 Jul 2017 09:39:04 +0000 (+0200) Subject: MEDIUM: threads/lua: Makes the jmpbuf and some other buffers local to the current... X-Git-Tag: v1.8-rc1~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ffbad790276486fe16326571d9d406e4188aebdf;p=thirdparty%2Fhaproxy.git MEDIUM: threads/lua: Makes the jmpbuf and some other buffers local to the current thread. The jmpbuf contains pointer on the stack memory address currently use when the jmpbuf is set. So the information is local to each thread. The struct field is too big to put it in the stack, but it is used as buffer for retriving stats values. So, this buffer si local to each threads. Each function using this buffer, use it whithout break (yield) so, the consistency of local buffer is ensured. --- diff --git a/src/hlua.c b/src/hlua.c index d5d07de347..81750564be 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -98,7 +98,7 @@ * because they must be exists in the program stack when the longjmp * is called. */ -jmp_buf safe_ljmp_env; +THREAD_LOCAL jmp_buf safe_ljmp_env; static int hlua_panic_safe(lua_State *L) { return 0; } static int hlua_panic_ljmp(lua_State *L) { longjmp(safe_ljmp_env, 1); } diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c index a5cae8676d..a4adb21781 100644 --- a/src/hlua_fcn.c +++ b/src/hlua_fcn.c @@ -40,7 +40,7 @@ static int class_regex_ref; #define STATS_LEN (MAX((int)ST_F_TOTAL_FIELDS, (int)INF_TOTAL_FIELDS)) -static struct field stats[STATS_LEN]; +static THREAD_LOCAL struct field stats[STATS_LEN]; int hlua_checkboolean(lua_State *L, int index) {