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.. */
} 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 *
**************************/

@ -47,3 +47,6 @@ worker_thread_get_memory_string(uint32_t offset, uint32_t max_length)
}
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)
{
assert(get_priority_fn != NULL);
assert(!software_interrupt_is_enabled());
/* Add one to capacity because this data structure ignores the element at 0 */
size_t one_based_capacity = capacity + 1;

@ -362,13 +362,12 @@ sandbox_close_http(struct sandbox *sandbox)
* sending, and cleanup
*/
void
current_sandbox_main(void)
sandbox_start(void)
{
struct sandbox *sandbox = current_sandbox_get();
assert(sandbox != NULL);
assert(sandbox->state == SANDBOX_RUNNING);
int rc;
char *error_message = "";
assert(!software_interrupt_is_enabled());
@ -380,8 +379,7 @@ current_sandbox_main(void)
sandbox_open_http(sandbox);
/* Parse the request */
rc = sandbox_receive_and_parse_client_request(sandbox);
if (rc < 0) {
if (sandbox_receive_and_parse_client_request(sandbox) < 0) {
error_message = "Unable to receive and parse client request\n";
goto err;
};
@ -401,8 +399,7 @@ current_sandbox_main(void)
sandbox->completion_timestamp = __getcycles();
/* Retrieve the result, construct the HTTP response, and send to client */
rc = sandbox_build_and_send_client_response(sandbox);
if (rc < 0) {
if (sandbox_build_and_send_client_response(sandbox) < 0) {
error_message = "Unable to build and send client response\n";
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 */
/* 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,
(reg_t)sandbox->stack_start + sandbox->stack_size);
arch_context_init(&sandbox->ctxt, (reg_t)sandbox_start, (reg_t)sandbox->stack_start + sandbox->stack_size);
/* Initialize file descriptors to -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
*/
__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());
generic_thread_dump_lock_overhead();
worker_thread_switch_to_base_context();

Loading…
Cancel
Save