diff options
author | Ippolitov Igor <iippolitov@nginx.com> | 2023-10-19 12:50:39 +0100 |
---|---|---|
committer | Ippolitov Igor <iippolitov@nginx.com> | 2023-10-19 12:50:39 +0100 |
commit | c43629880472bba8d389dfb0b7ae6d883b0ba499 (patch) | |
tree | acecdcb36cfb85fac3d8cdbfbe473c26ac2e2686 /src/wasm/nxt_rt_wasmtime.c | |
parent | 8c4425ccb9a413e8d0506e0254f0e84bd89a32a6 (diff) | |
parent | fb33ec86a3b6ca6a844dfa6980bb9e083094abec (diff) | |
download | unit-1.31.1-1.tar.gz unit-1.31.1-1.tar.bz2 |
Merged with the default branch.1.31.1-1
Diffstat (limited to 'src/wasm/nxt_rt_wasmtime.c')
-rw-r--r-- | src/wasm/nxt_rt_wasmtime.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/wasm/nxt_rt_wasmtime.c b/src/wasm/nxt_rt_wasmtime.c index 99786b89..bf0b0a0f 100644 --- a/src/wasm/nxt_rt_wasmtime.c +++ b/src/wasm/nxt_rt_wasmtime.c @@ -102,6 +102,19 @@ nxt_wasm_send_headers(void *env, wasmtime_caller_t *caller, } +static wasm_trap_t * +nxt_wasm_set_resp_status(void *env, wasmtime_caller_t *caller, + const wasmtime_val_t *args, size_t nargs, + wasmtime_val_t *results, size_t nresults) +{ + nxt_wasm_ctx_t *ctx = env; + + ctx->status = args[0].of.i32; + + return NULL; +} + + static void nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook) { @@ -123,7 +136,7 @@ nxt_wasmtime_execute_hook(const nxt_wasm_ctx_t *ctx, nxt_wasm_fh_t hook) } -static void +static int nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx) { int i = 0; @@ -142,7 +155,10 @@ nxt_wasmtime_execute_request(const nxt_wasm_ctx_t *ctx) nxt_wasmtime_err_msg(error, trap, "failed to call function [->wasm_request_handler]" ); + return -1; } + + return results[0].of.i32; } @@ -183,6 +199,11 @@ nxt_wasmtime_set_function_imports(nxt_wasm_ctx_t *ctx) .func = nxt_wasm_send_headers, .params = { WASM_I32 }, .ft = NXT_WASM_FT_1_0 + }, { + .func_name = "nxt_wasm_set_resp_status", + .func = nxt_wasm_set_resp_status, + .params = { WASM_I32 }, + .ft = NXT_WASM_FT_1_0 }, { } |