refactor: free linear memory func

main
Sean McBride 4 years ago
parent 7dc4488d74
commit 33d65605b1

@ -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);

@ -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

@ -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();

Loading…
Cancel
Save