mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-08 02:01:33 +00:00
OPTIM/MEDIUM: lua: executes the garbage collector only when using cosocket
The garbage collector is a little bit heavy to run, and it was added only for cosockets. This patch prevent useless executions when no cosockets are used.
This commit is contained in:
parent
6ab4d8ec0e
commit
7c39ab4ac2
@ -25,6 +25,7 @@ struct stream;
|
|||||||
#define HLUA_WAKERESWR 0x00000004
|
#define HLUA_WAKERESWR 0x00000004
|
||||||
#define HLUA_WAKEREQWR 0x00000008
|
#define HLUA_WAKEREQWR 0x00000008
|
||||||
#define HLUA_EXIT 0x00000010
|
#define HLUA_EXIT 0x00000010
|
||||||
|
#define HLUA_MUST_GC 0x00000020
|
||||||
|
|
||||||
enum hlua_exec {
|
enum hlua_exec {
|
||||||
HLUA_E_OK = 0,
|
HLUA_E_OK = 0,
|
||||||
|
13
src/hlua.c
13
src/hlua.c
@ -923,9 +923,11 @@ void hlua_ctx_destroy(struct hlua *lua)
|
|||||||
* NOTE: maybe this action locks all the Lua threads untiml the en of
|
* NOTE: maybe this action locks all the Lua threads untiml the en of
|
||||||
* the garbage collection.
|
* the garbage collection.
|
||||||
*/
|
*/
|
||||||
lua_gc(lua->T, LUA_GCCOLLECT, 0);
|
if (lua->flags & HLUA_MUST_GC) {
|
||||||
if (lua_status(lua->T) != LUA_OK)
|
lua_gc(lua->T, LUA_GCCOLLECT, 0);
|
||||||
lua_gc(gL.T, LUA_GCCOLLECT, 0);
|
if (lua_status(lua->T) != LUA_OK)
|
||||||
|
lua_gc(gL.T, LUA_GCCOLLECT, 0);
|
||||||
|
}
|
||||||
|
|
||||||
lua->T = NULL;
|
lua->T = NULL;
|
||||||
}
|
}
|
||||||
@ -1166,7 +1168,8 @@ timeout_reached:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This GC permits to destroy some object when a Lua timeout strikes. */
|
/* This GC permits to destroy some object when a Lua timeout strikes. */
|
||||||
if (ret != HLUA_E_AGAIN)
|
if (lua->flags & HLUA_MUST_GC &&
|
||||||
|
ret != HLUA_E_AGAIN)
|
||||||
lua_gc(lua->T, LUA_GCCOLLECT, 0);
|
lua_gc(lua->T, LUA_GCCOLLECT, 0);
|
||||||
|
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
@ -2253,6 +2256,8 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
|
|||||||
si_applet_cant_put(&socket->s->si[0]);
|
si_applet_cant_put(&socket->s->si[0]);
|
||||||
appctx_wakeup(appctx);
|
appctx_wakeup(appctx);
|
||||||
|
|
||||||
|
hlua->flags |= HLUA_MUST_GC;
|
||||||
|
|
||||||
if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
|
if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
|
||||||
WILL_LJMP(luaL_error(L, "out of memory"));
|
WILL_LJMP(luaL_error(L, "out of memory"));
|
||||||
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_connect_yield, TICK_ETERNITY, 0));
|
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_connect_yield, TICK_ETERNITY, 0));
|
||||||
|
Loading…
Reference in New Issue
Block a user