Skip to content

Commit

Permalink
[wip] use lua_resume directly!
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hishamhm committed Nov 8, 2023
1 parent d72f8de commit fb49309
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/common/lua/ngx_wasm_lua_ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ property_handler(void *data, ngx_str_t *key, ngx_str_t *value)
ngx_wasm_ffi_host_property_req_ctx_t hprctx;
ngx_proxy_wasm_ctx_t *pwctx = get_pwctx(hpctx->r);
lua_State *co;
ngx_int_t rc = NGX_OK;
ngx_wasm_lua_ctx_t *lctx;
int rv;

// FIXME if this function is changed to return NGX_AGAIN,
// hprctx needs to be dynamically allocated:
Expand Down Expand Up @@ -384,14 +384,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;
Expand Down

0 comments on commit fb49309

Please sign in to comment.