diff --git a/runtime/include/sandbox.h b/runtime/include/sandbox.h index ed5e216..a9cd53c 100644 --- a/runtime/include/sandbox.h +++ b/runtime/include/sandbox.h @@ -124,6 +124,7 @@ extern void worker_thread_wakeup_sandbox(struct sandbox *sandbox); struct sandbox *sandbox_allocate(struct sandbox_request *sandbox_request); void sandbox_free(struct sandbox *sandbox); +void sandbox_free_linear_memory(struct sandbox *sandbox); void sandbox_main(struct sandbox *sandbox); int sandbox_parse_http_request(struct sandbox *sandbox, size_t length); diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index 53f1972..fa923b1 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -484,6 +484,17 @@ err: goto done; } +/** + * Free Linear Memory, leaving stack in place + * @param sandbox + **/ +void +sandbox_free_linear_memory(struct sandbox *sandbox) +{ + int rc = munmap(sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE); + if (rc == -1) panic("sandbox_free_linear_memory - munmap failed\n"); +} + /** * Free stack and heap resources.. also any I/O handles. * @param sandbox diff --git a/runtime/src/worker_thread.c b/runtime/src/worker_thread.c index 3fd445e..75a2401 100644 --- a/runtime/src/worker_thread.c +++ b/runtime/src/worker_thread.c @@ -263,8 +263,7 @@ worker_thread_on_sandbox_exit(struct sandbox *exiting_sandbox) /* Because the stack is still in use, only unmap linear memory and defer free resources until "main function execution" */ - int rc = munmap(exiting_sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE); - if (rc == -1) perror("worker_thread_on_sandbox_exit - munmap failed\n"); + sandbox_free_linear_memory(exiting_sandbox); /* TODO: I do not understand when software interrupts must be disabled? */ software_interrupt_disable();