Skip to content

Commit

Permalink
refactor(lua-bridge) remove entry thread sleep timer handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thibaultcha committed Jun 10, 2024
1 parent 0856425 commit 64b5d7b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
27 changes: 0 additions & 27 deletions src/common/lua/ngx_wasm_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ entry_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);
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion src/common/lua/ngx_wasm_lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 64b5d7b

Please sign in to comment.