diff --git a/runtime/include/runtime.h b/runtime/include/runtime.h index b684b61..9d14813 100644 --- a/runtime/include/runtime.h +++ b/runtime/include/runtime.h @@ -10,7 +10,6 @@ extern int runtime_epoll_file_descriptor; extern __thread uv_loop_t worker_thread_uvio_handle; -extern float runtime_processor_speed_MHz; void alloc_linear_memory(void); void expand_memory(void); diff --git a/runtime/include/sandbox.h b/runtime/include/sandbox.h index d3d6b1a..1ae17a6 100644 --- a/runtime/include/sandbox.h +++ b/runtime/include/sandbox.h @@ -3,6 +3,8 @@ #include #include +#include +#include "sandbox_request.h" #include "arch/context.h" #include "deque.h" @@ -95,8 +97,10 @@ extern void worker_thread_wakeup_sandbox(sandbox_t *sandbox); * Public API * **************************/ -struct sandbox *sandbox_allocate(struct module *module, char *arguments, int socket_descriptor, - const struct sockaddr *socket_address, u64 start_time, u64 absolute_deadline); +// TODO: Why do I have to redeclare this type here? +typedef struct sandbox_request sandbox_request_t; + +struct sandbox *sandbox_allocate(sandbox_request_t *sandbox_request); void sandbox_free(struct sandbox *sandbox); int sandbox_parse_http_request(struct sandbox *sandbox, size_t length); diff --git a/runtime/include/sandbox_request.h b/runtime/include/sandbox_request.h index ec5c143..ca1b677 100644 --- a/runtime/include/sandbox_request.h +++ b/runtime/include/sandbox_request.h @@ -5,6 +5,8 @@ #include "types.h" #include "runtime.h" +extern float runtime_processor_speed_MHz; + struct sandbox_request { struct module * module; char * arguments; @@ -13,6 +15,7 @@ struct sandbox_request { u64 start_time; // cycles u64 absolute_deadline; // cycles }; + typedef struct sandbox_request sandbox_request_t; DEQUE_PROTOTYPE(sandbox, sandbox_request_t *); diff --git a/runtime/src/runtime.c b/runtime/src/runtime.c index 5926c30..d736690 100644 --- a/runtime/src/runtime.c +++ b/runtime/src/runtime.c @@ -265,10 +265,7 @@ worker_thread_pull_and_process_sandbox_requests(void) sandbox_request_t *sandbox_request; if ((sandbox_request = sandbox_request_scheduler_remove()) == NULL) break; // Actually allocate the sandbox for the requests that we've pulled - struct sandbox *sandbox = sandbox_allocate(sandbox_request->module, sandbox_request->arguments, - sandbox_request->socket_descriptor, - sandbox_request->socket_address, sandbox_request->start_time, - sandbox_request->absolute_deadline); + struct sandbox *sandbox = sandbox_allocate(sandbox_request); assert(sandbox); free(sandbox_request); // Set the sandbox as runnable and place on the local runqueue diff --git a/runtime/src/sandbox.c b/runtime/src/sandbox.c index 90c1694..c845848 100644 --- a/runtime/src/sandbox.c +++ b/runtime/src/sandbox.c @@ -307,9 +307,15 @@ sandbox_allocate_memory(struct module *module) } struct sandbox * -sandbox_allocate(struct module *module, char *arguments, int socket_descriptor, const struct sockaddr *socket_address, - u64 start_time, u64 absolute_deadline) +sandbox_allocate(sandbox_request_t *sandbox_request) { + struct module * module = sandbox_request->module; + char * arguments = sandbox_request->arguments; + int socket_descriptor = sandbox_request->socket_descriptor; + const struct sockaddr *socket_address = sandbox_request->socket_address; + u64 start_time = sandbox_request->start_time; + u64 absolute_deadline = sandbox_request->absolute_deadline; + if (!module_is_valid(module)) return NULL; // FIXME: don't use malloc. huge security problem!