From 2f56de3bf6dc12baecc61d1a16915e2746808f33 Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Wed, 29 May 2024 16:10:37 -0700 Subject: [PATCH] refactor(lua-bridge) remove entry thread sleep timer handling The invocation of `coctx->cleanup` previously introduced allows removing this custom handling of pending sleep timers added to the Lua bridge. Kept as a commit for future reference. --- src/common/lua/ngx_wasm_lua.c | 27 --------------------------- src/common/lua/ngx_wasm_lua.h | 1 - 2 files changed, 28 deletions(-) diff --git a/src/common/lua/ngx_wasm_lua.c b/src/common/lua/ngx_wasm_lua.c index 0055bf07d..43c0c2c38 100644 --- a/src/common/lua/ngx_wasm_lua.c +++ b/src/common/lua/ngx_wasm_lua.c @@ -69,11 +69,6 @@ thread_cleanup_handler(void *data) dd("enter"); - if (lctx->entry && lctx->ev && lctx->ev->timer_set) { - dd("delete pending timer event"); - ngx_event_del_timer(lctx->ev); - } - destroy_thread(lctx); } @@ -252,7 +247,6 @@ static ngx_inline ngx_int_t thread_handle_rc(ngx_wasm_lua_ctx_t *lctx, ngx_int_t rc) { ngx_wasm_subsys_env_t *env = lctx->env; - ngx_wasm_lua_ctx_t *entry_lctx = env->entry_lctx; dd("enter (rc: %ld, lctx: %p)", rc, lctx); @@ -285,27 +279,6 @@ thread_handle_rc(ngx_wasm_lua_ctx_t *lctx, ngx_int_t rc) case NGX_AGAIN: dd("wasm lua thread yield"); ngx_wa_assert(lctx->yielded); - - if (lctx->entry) { - /* find the pending sleep timer to cancel at pool cleanup */ - sentinel = ngx_event_timer_rbtree.sentinel; - root = ngx_event_timer_rbtree.root; - - if (root != sentinel) { - for (node = ngx_rbtree_min(root, sentinel); - node; - node = ngx_rbtree_next(&ngx_event_timer_rbtree, node)) - { - ev = ngx_rbtree_data(node, ngx_event_t, timer); - - if (ev->data == entry_lctx->co_ctx) { - entry_lctx->ev = ev; - break; - } - } - } - } - ngx_wasm_yield(env); break; case NGX_OK: diff --git a/src/common/lua/ngx_wasm_lua.h b/src/common/lua/ngx_wasm_lua.h index 71236b9de..00d784a14 100644 --- a/src/common/lua/ngx_wasm_lua.h +++ b/src/common/lua/ngx_wasm_lua.h @@ -25,7 +25,6 @@ struct ngx_wasm_lua_ctx_s { ngx_wasm_subsys_env_t *env; ngx_wasm_lua_handler_pt error_handler; ngx_wasm_lua_handler_pt success_handler; - ngx_event_t *ev; /* entry lctx sleep event */ void *data; const char *code;