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;