refactor: small nits

main
Sean McBride 4 years ago
parent 71f74ff535
commit c226ff2e03

@ -103,15 +103,6 @@ struct sandbox {
char request_response_data[1]; /* of request_response_data_length, following sandbox mem.. */ char request_response_data[1]; /* of request_response_data_length, following sandbox mem.. */
} PAGE_ALIGNED; } PAGE_ALIGNED;
/***************************
* Externs *
**************************/
extern void worker_thread_block_current_sandbox(void);
extern void worker_thread_on_sandbox_exit(struct sandbox *sandbox);
extern void worker_thread_process_io(void);
extern void worker_thread_wakeup_sandbox(struct sandbox *sandbox);
/*************************** /***************************
* Public API * * Public API *
**************************/ **************************/

@ -47,3 +47,6 @@ worker_thread_get_memory_string(uint32_t offset, uint32_t max_length)
} }
return NULL; return NULL;
} }
void worker_thread_block_current_sandbox(void);
__attribute__((noreturn)) void worker_thread_on_sandbox_exit();

@ -180,7 +180,6 @@ struct priority_queue *
priority_queue_initialize(size_t capacity, bool use_lock, priority_queue_get_priority_fn_t get_priority_fn) priority_queue_initialize(size_t capacity, bool use_lock, priority_queue_get_priority_fn_t get_priority_fn)
{ {
assert(get_priority_fn != NULL); assert(get_priority_fn != NULL);
assert(!software_interrupt_is_enabled());
/* Add one to capacity because this data structure ignores the element at 0 */ /* Add one to capacity because this data structure ignores the element at 0 */
size_t one_based_capacity = capacity + 1; size_t one_based_capacity = capacity + 1;

@ -362,13 +362,12 @@ sandbox_close_http(struct sandbox *sandbox)
* sending, and cleanup * sending, and cleanup
*/ */
void void
current_sandbox_main(void) sandbox_start(void)
{ {
struct sandbox *sandbox = current_sandbox_get(); struct sandbox *sandbox = current_sandbox_get();
assert(sandbox != NULL); assert(sandbox != NULL);
assert(sandbox->state == SANDBOX_RUNNING); assert(sandbox->state == SANDBOX_RUNNING);
int rc;
char *error_message = ""; char *error_message = "";
assert(!software_interrupt_is_enabled()); assert(!software_interrupt_is_enabled());
@ -380,8 +379,7 @@ current_sandbox_main(void)
sandbox_open_http(sandbox); sandbox_open_http(sandbox);
/* Parse the request */ /* Parse the request */
rc = sandbox_receive_and_parse_client_request(sandbox); if (sandbox_receive_and_parse_client_request(sandbox) < 0) {
if (rc < 0) {
error_message = "Unable to receive and parse client request\n"; error_message = "Unable to receive and parse client request\n";
goto err; goto err;
}; };
@ -401,8 +399,7 @@ current_sandbox_main(void)
sandbox->completion_timestamp = __getcycles(); sandbox->completion_timestamp = __getcycles();
/* Retrieve the result, construct the HTTP response, and send to client */ /* Retrieve the result, construct the HTTP response, and send to client */
rc = sandbox_build_and_send_client_response(sandbox); if (sandbox_build_and_send_client_response(sandbox) < 0) {
if (rc < 0) {
error_message = "Unable to build and send client response\n"; error_message = "Unable to build and send client response\n";
goto err; goto err;
}; };
@ -561,8 +558,7 @@ sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sand
/* Initialize the sandbox's context, stack, and instruction pointer */ /* Initialize the sandbox's context, stack, and instruction pointer */
/* stack_start points to the bottom of the usable stack, so add stack_size to get to top */ /* stack_start points to the bottom of the usable stack, so add stack_size to get to top */
arch_context_init(&sandbox->ctxt, (reg_t)current_sandbox_main, arch_context_init(&sandbox->ctxt, (reg_t)sandbox_start, (reg_t)sandbox->stack_start + sandbox->stack_size);
(reg_t)sandbox->stack_start + sandbox->stack_size);
/* Initialize file descriptors to -1 */ /* Initialize file descriptors to -1 */
for (int i = 0; i < SANDBOX_MAX_IO_HANDLE_COUNT; i++) sandbox->io_handles[i].file_descriptor = -1; for (int i = 0; i < SANDBOX_MAX_IO_HANDLE_COUNT; i++) sandbox->io_handles[i].file_descriptor = -1;

@ -341,9 +341,8 @@ worker_thread_main(void *argument)
* releases the linear memory, and then returns to the base context * releases the linear memory, and then returns to the base context
*/ */
__attribute__((noreturn)) void __attribute__((noreturn)) void
worker_thread_on_sandbox_exit(struct sandbox *exiting_sandbox) worker_thread_on_sandbox_exit()
{ {
assert(exiting_sandbox);
assert(!software_interrupt_is_enabled()); assert(!software_interrupt_is_enabled());
generic_thread_dump_lock_overhead(); generic_thread_dump_lock_overhead();
worker_thread_switch_to_base_context(); worker_thread_switch_to_base_context();

Loading…
Cancel
Save