MINOR: lua-thread: Add the "thread" core variable

The goal is to allow execution of one main lua state per thread.

This commit introduces this variable in the core. Lua state initialized
by thread will have access to this variable, which reports the executing
thread. 0 indicates the shared thread. Programs which must be executed
only once can check for core.thread <= 1.
diff --git a/src/hlua.c b/src/hlua.c
index 34e7403..6153ab7 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -8397,11 +8397,11 @@
 	return ptr;
 }
 
-/* Ithis function can fail with an abort() due to an Lua critical error.
+/* This function can fail with an abort() due to a Lua critical error.
  * We are in the initialisation process of HAProxy, this abort() is
  * tolerated.
  */
-lua_State *hlua_init_state(void)
+lua_State *hlua_init_state(int thread_num)
 {
 	int i;
 	int idx;
@@ -8468,6 +8468,9 @@
 	/* This table entry is the object "core" base. */
 	lua_newtable(L);
 
+	/* set the thread id */
+	hlua_class_const_int(L, "thread", thread_num);
+
 	/* Push the loglevel constants. */
 	for (i = 0; i < NB_LOG_LEVELS; i++)
 		hlua_class_const_int(L, log_levels[i], i);
@@ -8993,7 +8996,7 @@
 }
 
 void hlua_init(void) {
-	gL.T = hlua_init_state();
+	gL.T = hlua_init_state(0);
 }
 
 static void hlua_deinit()