MINOR: lua-thread: Replace embedded struct hlua_function by a pointer

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

Because this struct will be filled after the configuration parser, we
cannot copy the content. The actual state of the Haproxy code doesn't
justify this change, it is an update preparing next steps.
diff --git a/include/haproxy/hlua-t.h b/include/haproxy/hlua-t.h
index 391310c..952ab7b 100644
--- a/include/haproxy/hlua-t.h
+++ b/include/haproxy/hlua-t.h
@@ -122,7 +122,7 @@
  * It contains the lua execution configuration.
  */
 struct hlua_rule {
-	struct hlua_function fcn;
+	struct hlua_function *fcn;
 	char **args;
 };
 
diff --git a/src/hlua.c b/src/hlua.c
index f6db9fe..c9c2117 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -4661,7 +4661,7 @@
 	}
 	if (!sl) {
 		hlua_pusherror(L, "Lua applet http '%s': Failed to create response.\n",
-		               appctx->appctx->rule->arg.hlua_rule->fcn.name);
+		               appctx->appctx->rule->arg.hlua_rule->fcn->name);
 		WILL_LJMP(lua_error(L));
 	}
 	sl->info.res.status = appctx->appctx->ctx.hlua_apphttp.status;
@@ -4670,7 +4670,7 @@
 	lua_pushvalue(L, 0);
 	if (lua_getfield(L, 1, "response") != LUA_TTABLE) {
 		hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response'] missing.\n",
-		               appctx->appctx->rule->arg.hlua_rule->fcn.name);
+		               appctx->appctx->rule->arg.hlua_rule->fcn->name);
 		WILL_LJMP(lua_error(L));
 	}
 
@@ -4680,7 +4680,7 @@
 		/* We expect a string as -2. */
 		if (lua_type(L, -2) != LUA_TSTRING) {
 			hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response'][] element must be a string. got %s.\n",
-				       appctx->appctx->rule->arg.hlua_rule->fcn.name,
+				       appctx->appctx->rule->arg.hlua_rule->fcn->name,
 			               lua_typename(L, lua_type(L, -2)));
 			WILL_LJMP(lua_error(L));
 		}
@@ -4689,7 +4689,7 @@
 		/* We expect an array as -1. */
 		if (lua_type(L, -1) != LUA_TTABLE) {
 			hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response']['%s'] element must be an table. got %s.\n",
-				       appctx->appctx->rule->arg.hlua_rule->fcn.name,
+				       appctx->appctx->rule->arg.hlua_rule->fcn->name,
 				       name,
 			               lua_typename(L, lua_type(L, -1)));
 			WILL_LJMP(lua_error(L));
@@ -4703,7 +4703,7 @@
 			/* We expect a number as -2. */
 			if (lua_type(L, -2) != LUA_TNUMBER) {
 				hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response']['%s'][] element must be a number. got %s.\n",
-					       appctx->appctx->rule->arg.hlua_rule->fcn.name,
+					       appctx->appctx->rule->arg.hlua_rule->fcn->name,
 					       name,
 				               lua_typename(L, lua_type(L, -2)));
 				WILL_LJMP(lua_error(L));
@@ -4713,7 +4713,7 @@
 			/* We expect a string as -2. */
 			if (lua_type(L, -1) != LUA_TSTRING) {
 				hlua_pusherror(L, "Lua applet http '%s': AppletHTTP['response']['%s'][%d] element must be a string. got %s.\n",
-					       appctx->appctx->rule->arg.hlua_rule->fcn.name,
+					       appctx->appctx->rule->arg.hlua_rule->fcn->name,
 					       name, id,
 				               lua_typename(L, lua_type(L, -1)));
 				WILL_LJMP(lua_error(L));
@@ -4730,7 +4730,7 @@
 				ret = h1_parse_cont_len_header(&h1m, &v);
 				if (ret < 0) {
 					hlua_pusherror(L, "Lua applet http '%s': Invalid '%s' header.\n",
-						       appctx->appctx->rule->arg.hlua_rule->fcn.name,
+						       appctx->appctx->rule->arg.hlua_rule->fcn->name,
 						       name);
 					WILL_LJMP(lua_error(L));
 				}
@@ -4741,7 +4741,7 @@
 			/* Add a new header */
 			if (!htx_add_header(htx, ist2(name, nlen), ist2(value, vlen))) {
 				hlua_pusherror(L, "Lua applet http '%s': Failed to add header '%s' in the response.\n",
-					       appctx->appctx->rule->arg.hlua_rule->fcn.name,
+					       appctx->appctx->rule->arg.hlua_rule->fcn->name,
 					       name);
 				WILL_LJMP(lua_error(L));
 			}
@@ -4787,7 +4787,7 @@
 		sl->flags |= (HTX_SL_F_XFER_ENC|H1_MF_CHNK|H1_MF_XFER_LEN);
 		if (!htx_add_header(htx, ist("transfer-encoding"), ist("chunked"))) {
 			hlua_pusherror(L, "Lua applet http '%s': Failed to add header 'transfer-encoding' in the response.\n",
-				       appctx->appctx->rule->arg.hlua_rule->fcn.name);
+				       appctx->appctx->rule->arg.hlua_rule->fcn->name);
 			WILL_LJMP(lua_error(L));
 		}
 	}
@@ -4795,7 +4795,7 @@
 	/* Finalize headers. */
 	if (!htx_add_endof(htx, HTX_BLK_EOH)) {
 		hlua_pusherror(L, "Lua applet http '%s': Failed create the response.\n",
-			       appctx->appctx->rule->arg.hlua_rule->fcn.name);
+			       appctx->appctx->rule->arg.hlua_rule->fcn->name);
 		WILL_LJMP(lua_error(L));
 	}
 
@@ -6812,12 +6812,12 @@
 		s->hlua = pool_alloc(pool_head_hlua);
 		if (!s->hlua) {
 			SEND_ERR(px, "Lua action '%s': can't initialize Lua context.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			goto end;
 		}
 		if (!hlua_ctx_init(s->hlua, s->task, 0)) {
 			SEND_ERR(px, "Lua action '%s': can't initialize Lua context.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			goto end;
 		}
 	}
@@ -6832,25 +6832,25 @@
 			else
 				error = "critical error";
 			SEND_ERR(px, "Lua function '%s': %s.\n",
-			         rule->arg.hlua_rule->fcn.name, error);
+			         rule->arg.hlua_rule->fcn->name, error);
 			goto end;
 		}
 
 		/* Check stack available size. */
 		if (!lua_checkstack(s->hlua->T, 1)) {
 			SEND_ERR(px, "Lua function '%s': full stack.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			RESET_SAFE_LJMP(s->hlua->T);
 			goto end;
 		}
 
 		/* Restore the function in the stack. */
-		lua_rawgeti(s->hlua->T, LUA_REGISTRYINDEX, rule->arg.hlua_rule->fcn.function_ref);
+		lua_rawgeti(s->hlua->T, LUA_REGISTRYINDEX, rule->arg.hlua_rule->fcn->function_ref);
 
 		/* Create and and push object stream in the stack. */
 		if (!hlua_txn_new(s->hlua->T, s, px, dir, hflags)) {
 			SEND_ERR(px, "Lua function '%s': full stack.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			RESET_SAFE_LJMP(s->hlua->T);
 			goto end;
 		}
@@ -6860,7 +6860,7 @@
 		for (arg = rule->arg.hlua_rule->args; arg && *arg; arg++) {
 			if (!lua_checkstack(s->hlua->T, 1)) {
 				SEND_ERR(px, "Lua function '%s': full stack.\n",
-				         rule->arg.hlua_rule->fcn.name);
+				         rule->arg.hlua_rule->fcn->name);
 				RESET_SAFE_LJMP(s->hlua->T);
 				goto end;
 			}
@@ -6922,29 +6922,29 @@
 	case HLUA_E_ERRMSG:
 		/* Display log. */
 		SEND_ERR(px, "Lua function '%s': %s.\n",
-		         rule->arg.hlua_rule->fcn.name, lua_tostring(s->hlua->T, -1));
+		         rule->arg.hlua_rule->fcn->name, lua_tostring(s->hlua->T, -1));
 		lua_pop(s->hlua->T, 1);
 		goto end;
 
 	case HLUA_E_ETMOUT:
-		SEND_ERR(px, "Lua function '%s': execution timeout.\n", rule->arg.hlua_rule->fcn.name);
+		SEND_ERR(px, "Lua function '%s': execution timeout.\n", rule->arg.hlua_rule->fcn->name);
 		goto end;
 
 	case HLUA_E_NOMEM:
-		SEND_ERR(px, "Lua function '%s': out of memory error.\n", rule->arg.hlua_rule->fcn.name);
+		SEND_ERR(px, "Lua function '%s': out of memory error.\n", rule->arg.hlua_rule->fcn->name);
 		goto end;
 
 	case HLUA_E_YIELD:
 	  err_yield:
 		act_ret = ACT_RET_CONT;
 		SEND_ERR(px, "Lua function '%s': aborting Lua processing on expired timeout.\n",
-		         rule->arg.hlua_rule->fcn.name);
+		         rule->arg.hlua_rule->fcn->name);
 		goto end;
 
 	case HLUA_E_ERR:
 		/* Display log. */
 		SEND_ERR(px, "Lua function '%s' return an unknown error.\n",
-		         rule->arg.hlua_rule->fcn.name);
+		         rule->arg.hlua_rule->fcn->name);
 
 	default:
 		goto end;
@@ -6976,7 +6976,7 @@
 	hlua = pool_alloc(pool_head_hlua);
 	if (!hlua) {
 		SEND_ERR(px, "Lua applet tcp '%s': out of memory.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		return 0;
 	}
 	HLUA_INIT(hlua);
@@ -6987,7 +6987,7 @@
 	task = task_new(tid_bit);
 	if (!task) {
 		SEND_ERR(px, "Lua applet tcp '%s': out of memory.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		return 0;
 	}
 	task->nice = 0;
@@ -7002,7 +7002,7 @@
 	 */
 	if (!hlua_ctx_init(hlua, task, 0)) {
 		SEND_ERR(px, "Lua applet tcp '%s': can't initialize Lua context.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		return 0;
 	}
 
@@ -7016,25 +7016,25 @@
 		else
 			error = "critical error";
 		SEND_ERR(px, "Lua applet tcp '%s': %s.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name, error);
+		         ctx->rule->arg.hlua_rule->fcn->name, error);
 		return 0;
 	}
 
 	/* Check stack available size. */
 	if (!lua_checkstack(hlua->T, 1)) {
 		SEND_ERR(px, "Lua applet tcp '%s': full stack.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		RESET_SAFE_LJMP(hlua->T);
 		return 0;
 	}
 
 	/* Restore the function in the stack. */
-	lua_rawgeti(hlua->T, LUA_REGISTRYINDEX, ctx->rule->arg.hlua_rule->fcn.function_ref);
+	lua_rawgeti(hlua->T, LUA_REGISTRYINDEX, ctx->rule->arg.hlua_rule->fcn->function_ref);
 
 	/* Create and and push object stream in the stack. */
 	if (!hlua_applet_tcp_new(hlua->T, ctx)) {
 		SEND_ERR(px, "Lua applet tcp '%s': full stack.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		RESET_SAFE_LJMP(hlua->T);
 		return 0;
 	}
@@ -7044,7 +7044,7 @@
 	for (arg = ctx->rule->arg.hlua_rule->args; arg && *arg; arg++) {
 		if (!lua_checkstack(hlua->T, 1)) {
 			SEND_ERR(px, "Lua applet tcp '%s': full stack.\n",
-			         ctx->rule->arg.hlua_rule->fcn.name);
+			         ctx->rule->arg.hlua_rule->fcn->name);
 			RESET_SAFE_LJMP(hlua->T);
 			return 0;
 		}
@@ -7103,29 +7103,29 @@
 	case HLUA_E_ERRMSG:
 		/* Display log. */
 		SEND_ERR(px, "Lua applet tcp '%s': %s.\n",
-		         rule->arg.hlua_rule->fcn.name, lua_tostring(hlua->T, -1));
+		         rule->arg.hlua_rule->fcn->name, lua_tostring(hlua->T, -1));
 		lua_pop(hlua->T, 1);
 		goto error;
 
 	case HLUA_E_ETMOUT:
 		SEND_ERR(px, "Lua applet tcp '%s': execution timeout.\n",
-		         rule->arg.hlua_rule->fcn.name);
+		         rule->arg.hlua_rule->fcn->name);
 		goto error;
 
 	case HLUA_E_NOMEM:
 		SEND_ERR(px, "Lua applet tcp '%s': out of memory error.\n",
-		         rule->arg.hlua_rule->fcn.name);
+		         rule->arg.hlua_rule->fcn->name);
 		goto error;
 
 	case HLUA_E_YIELD: /* unexpected */
 		SEND_ERR(px, "Lua applet tcp '%s': yield not allowed.\n",
-		         rule->arg.hlua_rule->fcn.name);
+		         rule->arg.hlua_rule->fcn->name);
 		goto error;
 
 	case HLUA_E_ERR:
 		/* Display log. */
 		SEND_ERR(px, "Lua applet tcp '%s' return an unknown error.\n",
-		         rule->arg.hlua_rule->fcn.name);
+		         rule->arg.hlua_rule->fcn->name);
 		goto error;
 
 	default:
@@ -7165,7 +7165,7 @@
 	hlua = pool_alloc(pool_head_hlua);
 	if (!hlua) {
 		SEND_ERR(px, "Lua applet http '%s': out of memory.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		return 0;
 	}
 	HLUA_INIT(hlua);
@@ -7180,7 +7180,7 @@
 	task = task_new(tid_bit);
 	if (!task) {
 		SEND_ERR(px, "Lua applet http '%s': out of memory.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		return 0;
 	}
 	task->nice = 0;
@@ -7195,7 +7195,7 @@
 	 */
 	if (!hlua_ctx_init(hlua, task, 0)) {
 		SEND_ERR(px, "Lua applet http '%s': can't initialize Lua context.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		return 0;
 	}
 
@@ -7209,25 +7209,25 @@
 		else
 			error = "critical error";
 		SEND_ERR(px, "Lua applet http '%s': %s.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name, error);
+		         ctx->rule->arg.hlua_rule->fcn->name, error);
 		return 0;
 	}
 
 	/* Check stack available size. */
 	if (!lua_checkstack(hlua->T, 1)) {
 		SEND_ERR(px, "Lua applet http '%s': full stack.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		RESET_SAFE_LJMP(hlua->T);
 		return 0;
 	}
 
 	/* Restore the function in the stack. */
-	lua_rawgeti(hlua->T, LUA_REGISTRYINDEX, ctx->rule->arg.hlua_rule->fcn.function_ref);
+	lua_rawgeti(hlua->T, LUA_REGISTRYINDEX, ctx->rule->arg.hlua_rule->fcn->function_ref);
 
 	/* Create and and push object stream in the stack. */
 	if (!hlua_applet_http_new(hlua->T, ctx)) {
 		SEND_ERR(px, "Lua applet http '%s': full stack.\n",
-		         ctx->rule->arg.hlua_rule->fcn.name);
+		         ctx->rule->arg.hlua_rule->fcn->name);
 		RESET_SAFE_LJMP(hlua->T);
 		return 0;
 	}
@@ -7237,7 +7237,7 @@
 	for (arg = ctx->rule->arg.hlua_rule->args; arg && *arg; arg++) {
 		if (!lua_checkstack(hlua->T, 1)) {
 			SEND_ERR(px, "Lua applet http '%s': full stack.\n",
-			         ctx->rule->arg.hlua_rule->fcn.name);
+			         ctx->rule->arg.hlua_rule->fcn->name);
 			RESET_SAFE_LJMP(hlua->T);
 			return 0;
 		}
@@ -7335,29 +7335,29 @@
 		case HLUA_E_ERRMSG:
 			/* Display log. */
 			SEND_ERR(px, "Lua applet http '%s': %s.\n",
-			         rule->arg.hlua_rule->fcn.name, lua_tostring(hlua->T, -1));
+			         rule->arg.hlua_rule->fcn->name, lua_tostring(hlua->T, -1));
 			lua_pop(hlua->T, 1);
 			goto error;
 
 		case HLUA_E_ETMOUT:
 			SEND_ERR(px, "Lua applet http '%s': execution timeout.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			goto error;
 
 		case HLUA_E_NOMEM:
 			SEND_ERR(px, "Lua applet http '%s': out of memory error.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			goto error;
 
 		case HLUA_E_YIELD: /* unexpected */
 			SEND_ERR(px, "Lua applet http '%s': yield not allowed.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			goto error;
 
 		case HLUA_E_ERR:
 			/* Display log. */
 			SEND_ERR(px, "Lua applet http '%s' return an unknown error.\n",
-			         rule->arg.hlua_rule->fcn.name);
+			         rule->arg.hlua_rule->fcn->name);
 			goto error;
 
 		default:
@@ -7461,7 +7461,7 @@
 	}
 
 	/* Reference the Lua function and store the reference. */
-	rule->arg.hlua_rule->fcn = *fcn;
+	rule->arg.hlua_rule->fcn = fcn;
 
 	/* Expect some arguments */
 	for (i = 0; i < fcn->nargs; i++) {
@@ -7507,7 +7507,7 @@
 	}
 
 	/* Reference the Lua function and store the reference. */
-	rule->arg.hlua_rule->fcn = *fcn;
+	rule->arg.hlua_rule->fcn = fcn;
 
 	/* TODO: later accept arguments. */
 	rule->arg.hlua_rule->args = NULL;
@@ -7654,7 +7654,7 @@
 	}
 
 	/* Reference the Lua function and store the reference. */
-	rule->arg.hlua_rule->fcn = *fcn;
+	rule->arg.hlua_rule->fcn = fcn;
 
 	/* TODO: later accept arguments. */
 	rule->arg.hlua_rule->args = NULL;