static int hlua_panic_safe(lua_State *L) { return 0; }
static int hlua_panic_ljmp(lua_State *L) { WILL_LJMP(longjmp(safe_ljmp_env, 1)); }
+/* This is the chained list of struct hlua_function referenced
+ * for haproxy action, sample-fetches, converters, cli and
+ * applet bindings. It is used for a post-initialisation control.
+ */
+static struct list referenced_functions = LIST_HEAD_INIT(referenced_functions);
+
#define SET_SAFE_LJMP_L(__L, __HLUA) \
({ \
int ret; \
ha_alert(__fmt, ## __args); \
} while (0)
+static inline struct hlua_function *new_hlua_function()
+{
+ struct hlua_function *fcn;
+
+ fcn = calloc(1, sizeof(*fcn));
+ if (!fcn)
+ return NULL;
+ LIST_ADDQ(&referenced_functions, &fcn->l);
+ return fcn;
+}
+
/* Used to check an Lua function type in the stack. It creates and
* returns a reference of the function. This function throws an
* error if the rgument is not a "function".
sck = calloc(1, sizeof(*sck) + sizeof(struct sample_conv) * 2);
if (!sck)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
- fcn = calloc(1, sizeof(*fcn));
+ fcn = new_hlua_function();
if (!fcn)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
sfk = calloc(1, sizeof(*sfk) + sizeof(struct sample_fetch) * 2);
if (!sfk)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
- fcn = calloc(1, sizeof(*fcn));
+ fcn = new_hlua_function();
if (!fcn)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
akl = calloc(1, sizeof(*akl) + sizeof(struct action_kw) * 2);
if (!akl)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
- fcn = calloc(1, sizeof(*fcn));
+ fcn = new_hlua_function();
if (!fcn)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
akl = calloc(1, sizeof(*akl) + sizeof(struct action_kw) * 2);
if (!akl)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
- fcn = calloc(1, sizeof(*fcn));
+ fcn = new_hlua_function();
if (!fcn)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
cli_kws = calloc(1, sizeof(*cli_kws) + sizeof(struct cli_kw) * 2);
if (!cli_kws)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));
- fcn = calloc(1, sizeof(*fcn));
+ fcn = new_hlua_function();
if (!fcn)
WILL_LJMP(luaL_error(L, "Lua out of memory error."));