* NOTE: maybe this action locks all the Lua threads untiml the en of
* the garbage collection.
*/
- lua_gc(lua->T, LUA_GCCOLLECT, 0);
- if (lua_status(lua->T) != LUA_OK)
- lua_gc(gL.T, LUA_GCCOLLECT, 0);
+ if (lua->flags & HLUA_MUST_GC) {
+ lua_gc(lua->T, LUA_GCCOLLECT, 0);
+ if (lua_status(lua->T) != LUA_OK)
+ lua_gc(gL.T, LUA_GCCOLLECT, 0);
+ }
lua->T = NULL;
}
}
/* 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);
switch (ret) {
si_applet_cant_put(&socket->s->si[0]);
appctx_wakeup(appctx);
+ hlua->flags |= HLUA_MUST_GC;
+
if (!hlua_com_new(hlua, &appctx->ctx.hlua.wake_on_write))
WILL_LJMP(luaL_error(L, "out of memory"));
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_socket_connect_yield, TICK_ETERNITY, 0));