From e077a6670e59040e084669e66e5190cd92500c73 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 7 Nov 2023 19:34:47 -0300 Subject: [PATCH] [wip] use lua_resume directly! This makes other tests pass, but this is very WIP because it doesn't destroy the thread, etc. Some setup is going wrong when running this because this change produces segfaults with `r->connection->pool` being unset. --- src/common/lua/ngx_wasm_lua_ffi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/lua/ngx_wasm_lua_ffi.c b/src/common/lua/ngx_wasm_lua_ffi.c index f6bdf0b74..c3b50e1b5 100644 --- a/src/common/lua/ngx_wasm_lua_ffi.c +++ b/src/common/lua/ngx_wasm_lua_ffi.c @@ -332,7 +332,7 @@ property_handler(void *data, ngx_str_t *key, ngx_str_t *value) lua_State *co; ngx_int_t rc = NGX_OK; ngx_wasm_lua_ctx_t *lctx; - int top; + int rv; // FIXME if this function is changed to return NGX_AGAIN, // hprctx needs to be dynamically allocated: @@ -379,14 +379,21 @@ property_handler(void *data, ngx_str_t *key, ngx_str_t *value) /* run handler */ - rc = ngx_wasm_lua_thread_run(lctx); - if (rc == NGX_AGAIN) { + rv = lua_resume(lctx->co, lctx->nargs); + if (rv == LUA_YIELD) { ngx_wavm_log_error(NGX_LOG_ERR, pwctx->log, NULL, "cannot yield from host property handler"); return NGX_ERROR; } + if (rv != 0) { + ngx_wavm_log_error(NGX_LOG_ERR, pwctx->log, NULL, + "Lua resume failed with error: %d", rv); + + return NGX_ERROR; + } + // ngx_wasm_assert(rc == NGX_DONE); return hprctx.rc;