]> git.kaiwu.me - haproxy.git/commit
MINOR: lua: add REGISTER_HLUA_STATE_INIT() to register state init callbacks
authorWilliam Lallemand <wlallemand@haproxy.com>
Wed, 10 Jun 2026 13:03:05 +0000 (15:03 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 11 Jun 2026 12:13:04 +0000 (14:13 +0200)
commitd0fde90e16515a57f08288e23cbde3bbe1a3b013
tree2a7f619ffdb444484b20323f64cc9662c2527be5
parent3dfd86062b9edf30f48701413ade565d67d3c1bb
MINOR: lua: add REGISTER_HLUA_STATE_INIT() to register state init callbacks

Add a registration mechanism so that modules outside of hlua.c can hook
into each lua_State creation. Modules call hap_register_hlua_state_init()
(or the REGISTER_HLUA_STATE_INIT() macro) with a callback of the form:

  int my_init(lua_State *L, char **errmsg);

The callback returns an ERR_* code. ERR_ALERT and ERR_WARN trigger
ha_alert()/ha_warning() respectively; any other non-zero errmsg is
emitted via ha_notice(). ERR_FATAL or ERR_ABORT cause exit(1).
Registered entries are freed in hlua_deinit().
doc/internals/api/initcalls.txt
include/haproxy/hlua-t.h
include/haproxy/hlua.h
src/hlua.c