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); struct sandbox *sandbox_allocate(struct sandbox_request *sandbox_request);
void sandbox_free(struct sandbox *sandbox); void sandbox_free(struct sandbox *sandbox);
void sandbox_free_linear_memory(struct sandbox *sandbox);
void sandbox_main(struct sandbox *sandbox); void sandbox_main(struct sandbox *sandbox);
int sandbox_parse_http_request(struct sandbox *sandbox, size_t length); int sandbox_parse_http_request(struct sandbox *sandbox, size_t length);

@ -484,6 +484,17 @@ err:
goto done; 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. * Free stack and heap resources.. also any I/O handles.
* @param sandbox * @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 /* Because the stack is still in use, only unmap linear memory and defer free resources until "main
function execution" */ function execution" */
int rc = munmap(exiting_sandbox->linear_memory_start, SBOX_MAX_MEM + PAGE_SIZE); sandbox_free_linear_memory(exiting_sandbox);
if (rc == -1) perror("worker_thread_on_sandbox_exit - munmap failed\n");
/* TODO: I do not understand when software interrupts must be disabled? */ /* TODO: I do not understand when software interrupts must be disabled? */
software_interrupt_disable(); software_interrupt_disable();

Loading…
Cancel
Save