#define HLUA_WAKERESWR 0x00000004
#define HLUA_WAKEREQWR 0x00000008
#define HLUA_EXIT 0x00000010
-#define HLUA_MUST_GC 0x00000020
+/* unused: 0x00000020 */
#define HLUA_STOP 0x00000040
#define HLUA_F_AS_STRING 0x01
struct list com; /* The list head of the signals attached to this task. */
struct ebpt_node node;
struct hlua_consistency cons; /* Store data consistency check. */
+ int gc_count; /* number of items which need a GC */
};
/* This is a part of the list containing references to functions
}
lua->Mref = LUA_REFNIL;
lua->flags = 0;
+ lua->gc_count = 0;
LIST_INIT(&lua->com);
lua->T = lua_newthread(gL.T);
if (!lua->T) {
* NOTE: maybe this action locks all the Lua threads untiml the en of
* the garbage collection.
*/
- if (lua->flags & HLUA_MUST_GC) {
+ if (lua->gc_count) {
if (!SET_SAFE_LJMP(gL.T))
return;
lua_gc(gL.T, LUA_GCCOLLECT, 0);
break;
}
- /* This GC permits to destroy some object when a Lua timeout strikes. */
- if (lua->flags & HLUA_MUST_GC &&
- ret != HLUA_E_AGAIN)
- lua_gc(lua->T, LUA_GCCOLLECT, 0);
-
switch (ret) {
case HLUA_E_AGAIN:
break;
struct hlua_socket *socket;
struct appctx *appctx;
struct xref *peer;
+ struct hlua *hlua = hlua_gethlua(L);
socket = MAY_LJMP(hlua_checksocket(L, 1));
peer = xref_get_peer_and_lock(&socket->xref);
if (!peer)
return 0;
+
+ hlua->gc_count--;
appctx = container_of(peer, struct appctx, ctx.hlua_cosocket.xref);
/* Set the flag which destroy the session. */
si_rx_endp_more(&s->si[0]);
appctx_wakeup(appctx);
- hlua->flags |= HLUA_MUST_GC;
+ hlua->gc_count++;
if (!notification_new(&hlua->com, &appctx->ctx.hlua_cosocket.wake_on_write, hlua->task)) {
xref_unlock(&socket->xref, peer);