|
|
|
@ -25,6 +25,20 @@ sandbox_log_allocation(struct sandbox *sandbox)
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
init_response_body(struct sandbox *sandbox)
|
|
|
|
|
{
|
|
|
|
|
if (sandbox->response_body.data == NULL) {
|
|
|
|
|
int rc = auto_buf_init(&sandbox->response_body);
|
|
|
|
|
if (rc < 0) {
|
|
|
|
|
printf("failed to init http body autobuf, exit\n");
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Allocates a WebAssembly linear memory for a sandbox based on the starting_pages and max_pages globals present in
|
|
|
|
|
* the associated *.so module
|
|
|
|
@ -94,7 +108,8 @@ sandbox_prepare_execution_environment(struct sandbox *sandbox)
|
|
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
rc = http_session_init_response_body(sandbox->http);
|
|
|
|
|
//rc = http_session_init_response_body(sandbox->http);
|
|
|
|
|
rc = init_response_body(sandbox);
|
|
|
|
|
if (rc < 0) {
|
|
|
|
|
error_message = "failed to allocate response body";
|
|
|
|
|
goto err_globals_allocation_failed;
|
|
|
|
@ -135,6 +150,14 @@ err_http_allocation_failed:
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
deinit_response_body(struct sandbox *sandbox)
|
|
|
|
|
{
|
|
|
|
|
auto_buf_deinit(&sandbox->response_body);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
sandbox_init(struct sandbox *sandbox, struct module *module, struct http_session *session, struct route *route,
|
|
|
|
|
struct tenant *tenant, uint64_t admissions_estimate)
|
|
|
|
@ -211,6 +234,8 @@ sandbox_deinit(struct sandbox *sandbox)
|
|
|
|
|
/* Linear Memory and Guard Page should already have been munmaped and set to NULL */
|
|
|
|
|
assert(sandbox->memory == NULL);
|
|
|
|
|
|
|
|
|
|
deinit_response_body(sandbox);
|
|
|
|
|
|
|
|
|
|
if (likely(sandbox->stack != NULL)) sandbox_free_stack(sandbox);
|
|
|
|
|
if (likely(sandbox->globals.buffer != NULL)) sandbox_free_globals(sandbox);
|
|
|
|
|
if (likely(sandbox->wasi_context != NULL)) wasi_context_destroy(sandbox->wasi_context);
|
|
|
|
|