summaryrefslogtreecommitdiffhomepage
path: root/src/wasm/nxt_rt_wasmtime.c
diff options
context:
space:
mode:
authorIppolitov Igor <iippolitov@nginx.com>2023-10-19 12:50:39 +0100
committerIppolitov Igor <iippolitov@nginx.com>2023-10-19 12:50:39 +0100
commitc43629880472bba8d389dfb0b7ae6d883b0ba499 (patch)
treeacecdcb36cfb85fac3d8cdbfbe473c26ac2e2686 /src/wasm/nxt_rt_wasmtime.c
parent8c4425ccb9a413e8d0506e0254f0e84bd89a32a6 (diff)
parentfb33ec86a3b6ca6a844dfa6980bb9e083094abec (diff)
downloadunit-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.c23
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
},
{ }