diff --git a/runtime/include/sandbox_request.h b/runtime/include/sandbox_request.h index d9dfc25..4a84aaa 100644 --- a/runtime/include/sandbox_request.h +++ b/runtime/include/sandbox_request.h @@ -16,7 +16,6 @@ struct sandbox_request { uint64_t id; bool request_from_outside; /* true is yes, false is no */ - int current_func_index; struct module * module; char * arguments; int socket_descriptor; @@ -69,10 +68,10 @@ sandbox_request_log_allocation(struct sandbox_request *sandbox_request) * @return the new sandbox request */ static inline struct sandbox_request * -sandbox_request_allocate(struct module *module, bool request_from_outside, ssize_t request_length, int current_func_index, - char *arguments, int socket_descriptor, - const struct sockaddr *socket_address, uint64_t request_arrival_timestamp, - uint64_t admissions_estimate, char *previous_function_output, ssize_t output_length) +sandbox_request_allocate(struct module *module, bool request_from_outside, ssize_t request_length, + char *arguments, int socket_descriptor, const struct sockaddr *socket_address, + uint64_t request_arrival_timestamp, uint64_t admissions_estimate, + char *previous_function_output, ssize_t output_length) { struct sandbox_request *sandbox_request = (struct sandbox_request *)malloc(sizeof(struct sandbox_request)); assert(sandbox_request); @@ -82,7 +81,6 @@ sandbox_request_allocate(struct module *module, bool request_from_outside, ssize sandbox_request->module = module; sandbox_request->request_from_outside = request_from_outside; - sandbox_request->current_func_index = current_func_index; sandbox_request->arguments = arguments; sandbox_request->socket_descriptor = socket_descriptor; memcpy(&sandbox_request->socket_address, socket_address, sizeof(struct sockaddr)); diff --git a/runtime/include/sandbox_set_as_initialized.h b/runtime/include/sandbox_set_as_initialized.h index c3eb2e7..3413619 100644 --- a/runtime/include/sandbox_set_as_initialized.h +++ b/runtime/include/sandbox_set_as_initialized.h @@ -33,7 +33,6 @@ sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sand sandbox->allocation_timestamp = allocation_timestamp; sandbox->state = SANDBOX_SET_AS_INITIALIZED; - sandbox->current_func_index = sandbox_request->current_func_index; sandbox->request_from_outside = sandbox_request->request_from_outside; sandbox->previous_function_output = sandbox_request->previous_function_output; sandbox->output_length = sandbox_request->output_length; diff --git a/runtime/src/current_sandbox.c b/runtime/src/current_sandbox.c index 8be1b1a..9edd8e5 100644 --- a/runtime/src/current_sandbox.c +++ b/runtime/src/current_sandbox.c @@ -80,8 +80,8 @@ current_sandbox_start(void) goto err; }; } else { - // copy previous output to sandbox->request_response_data, as the input for the sandbox. - // let sandbox->http_request->body points to sandbox->request_response_data + /* copy previous output to sandbox->request_response_data, as the input for the sandbox.*/ + /* let sandbox->http_request->body points to sandbox->request_response_data*/ assert(sandbox->previous_function_output != NULL); memcpy(sandbox->request_response_data, sandbox->previous_function_output, sandbox->output_length); sandbox->http_request.body = sandbox->request_response_data; @@ -104,17 +104,13 @@ current_sandbox_start(void) struct module * next_module = sandbox->module->next_module; - //if (sandbox->current_func_index + 1 < g_chain_length) { if (next_module != NULL) { - //uint32_t next_port = g_single_function_flow_table[sandbox->current_func_index + 1]; - //struct module * next_module = get_module_from_ht(next_port); - //generate a new request, copy the current sandbox's output to the next request's buffer, and put it to the global queue - + /* Generate a new request, copy the current sandbox's output to the next request's buffer, and put it to the global queue */ ssize_t output_length = sandbox->request_response_data_length - sandbox->request_length; char * pre_func_output = (char *) malloc(output_length); memcpy(pre_func_output, sandbox->request_response_data + sandbox->request_length, output_length); struct sandbox_request *sandbox_request = - sandbox_request_allocate(next_module, false, sandbox->request_length, sandbox->current_func_index + 1, + sandbox_request_allocate(next_module, false, sandbox->request_length, next_module->name, sandbox->client_socket_descriptor, (const struct sockaddr *)&sandbox->client_address, sandbox->request_arrival_timestamp, true, pre_func_output, output_length); @@ -128,7 +124,7 @@ current_sandbox_start(void) } else { /* Retrieve the result, construct the HTTP response, and send to client */ if (sandbox_send_response(sandbox) < 0) { // if send blocked, remove the sandbox from the local runqueue - // and pause the sandbox + // and pause the sandbox error_message = "Unable to build and send client response\n"; goto err; }; @@ -139,8 +135,7 @@ current_sandbox_start(void) assert(sandbox->state == SANDBOX_RUNNING); sandbox_close_http(sandbox); - sandbox_set_as_returned(sandbox, SANDBOX_RUNNING); //request is completed, remove the sandbox from the - //local runqueue + sandbox_set_as_returned(sandbox, SANDBOX_RUNNING); //request is completed, remove the sandbox from the local runqueue } done: /* Cleanup connection and exit sandbox */ diff --git a/runtime/src/listener_thread.c b/runtime/src/listener_thread.c index f5b66cd..a9616c4 100644 --- a/runtime/src/listener_thread.c +++ b/runtime/src/listener_thread.c @@ -177,7 +177,7 @@ listener_thread_main(void *dummy) /* Allocate a Sandbox Request */ struct sandbox_request *sandbox_request = - sandbox_request_allocate(module, true, 0, 0, module->name, client_socket, + sandbox_request_allocate(module, true, 0, module->name, client_socket, (const struct sockaddr *)&client_address, request_arrival_timestamp, work_admitted, NULL, 0);