]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: threads/lua: Makes the jmpbuf and some other buffers local to the current...
authorThierry FOURNIER <thierry.fournier@ozon.io>
Wed, 12 Jul 2017 09:39:04 +0000 (11:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 31 Oct 2017 12:58:32 +0000 (13:58 +0100)
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.

src/hlua.c
src/hlua_fcn.c

index d5d07de3472043faa4fc8d411b478e82ba6816d5..81750564be9eb87313f82c13b2f6305d912d1038 100644 (file)
@@ -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); }
 
index a5cae8676de2e03e64e80f5fba318cf9a1d5eb22..a4adb21781be05cceec706c0f746e34ebe459680 100644 (file)
@@ -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)
 {