remove some redundant parameters

main
xiaosuGW 3 years ago
parent 3bbc2f28fd
commit a642082b73

@ -16,7 +16,6 @@
struct sandbox_request { struct sandbox_request {
uint64_t id; uint64_t id;
bool request_from_outside; /* true is yes, false is no */ bool request_from_outside; /* true is yes, false is no */
int current_func_index;
struct module * module; struct module * module;
char * arguments; char * arguments;
int socket_descriptor; int socket_descriptor;
@ -69,10 +68,10 @@ sandbox_request_log_allocation(struct sandbox_request *sandbox_request)
* @return the new sandbox request * @return the new sandbox request
*/ */
static inline struct 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, sandbox_request_allocate(struct module *module, bool request_from_outside, ssize_t request_length,
char *arguments, int socket_descriptor, char *arguments, int socket_descriptor, const struct sockaddr *socket_address,
const struct sockaddr *socket_address, uint64_t request_arrival_timestamp, uint64_t request_arrival_timestamp, uint64_t admissions_estimate,
uint64_t admissions_estimate, char *previous_function_output, ssize_t output_length) char *previous_function_output, ssize_t output_length)
{ {
struct sandbox_request *sandbox_request = (struct sandbox_request *)malloc(sizeof(struct sandbox_request)); struct sandbox_request *sandbox_request = (struct sandbox_request *)malloc(sizeof(struct sandbox_request));
assert(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->module = module;
sandbox_request->request_from_outside = request_from_outside; sandbox_request->request_from_outside = request_from_outside;
sandbox_request->current_func_index = current_func_index;
sandbox_request->arguments = arguments; sandbox_request->arguments = arguments;
sandbox_request->socket_descriptor = socket_descriptor; sandbox_request->socket_descriptor = socket_descriptor;
memcpy(&sandbox_request->socket_address, socket_address, sizeof(struct sockaddr)); memcpy(&sandbox_request->socket_address, socket_address, sizeof(struct sockaddr));

@ -33,7 +33,6 @@ sandbox_set_as_initialized(struct sandbox *sandbox, struct sandbox_request *sand
sandbox->allocation_timestamp = allocation_timestamp; sandbox->allocation_timestamp = allocation_timestamp;
sandbox->state = SANDBOX_SET_AS_INITIALIZED; 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->request_from_outside = sandbox_request->request_from_outside;
sandbox->previous_function_output = sandbox_request->previous_function_output; sandbox->previous_function_output = sandbox_request->previous_function_output;
sandbox->output_length = sandbox_request->output_length; sandbox->output_length = sandbox_request->output_length;

@ -80,8 +80,8 @@ current_sandbox_start(void)
goto err; goto err;
}; };
} else { } else {
// copy previous output to sandbox->request_response_data, as the input for the sandbox. /* 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 /* let sandbox->http_request->body points to sandbox->request_response_data*/
assert(sandbox->previous_function_output != NULL); assert(sandbox->previous_function_output != NULL);
memcpy(sandbox->request_response_data, sandbox->previous_function_output, sandbox->output_length); memcpy(sandbox->request_response_data, sandbox->previous_function_output, sandbox->output_length);
sandbox->http_request.body = sandbox->request_response_data; sandbox->http_request.body = sandbox->request_response_data;
@ -104,17 +104,13 @@ current_sandbox_start(void)
struct module * next_module = sandbox->module->next_module; struct module * next_module = sandbox->module->next_module;
//if (sandbox->current_func_index + 1 < g_chain_length) {
if (next_module != NULL) { if (next_module != NULL) {
//uint32_t next_port = g_single_function_flow_table[sandbox->current_func_index + 1]; /* Generate a new request, copy the current sandbox's output to the next request's buffer, and put it to the global queue */
//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
ssize_t output_length = sandbox->request_response_data_length - sandbox->request_length; ssize_t output_length = sandbox->request_response_data_length - sandbox->request_length;
char * pre_func_output = (char *) malloc(output_length); char * pre_func_output = (char *) malloc(output_length);
memcpy(pre_func_output, sandbox->request_response_data + sandbox->request_length, output_length); memcpy(pre_func_output, sandbox->request_response_data + sandbox->request_length, output_length);
struct sandbox_request *sandbox_request = 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, next_module->name, sandbox->client_socket_descriptor,
(const struct sockaddr *)&sandbox->client_address, (const struct sockaddr *)&sandbox->client_address,
sandbox->request_arrival_timestamp, true, pre_func_output, output_length); sandbox->request_arrival_timestamp, true, pre_func_output, output_length);
@ -128,7 +124,7 @@ current_sandbox_start(void)
} else { } else {
/* Retrieve the result, construct the HTTP response, and send to client */ /* 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 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"; error_message = "Unable to build and send client response\n";
goto err; goto err;
}; };
@ -139,8 +135,7 @@ current_sandbox_start(void)
assert(sandbox->state == SANDBOX_RUNNING); assert(sandbox->state == SANDBOX_RUNNING);
sandbox_close_http(sandbox); sandbox_close_http(sandbox);
sandbox_set_as_returned(sandbox, SANDBOX_RUNNING); //request is completed, remove the sandbox from the sandbox_set_as_returned(sandbox, SANDBOX_RUNNING); //request is completed, remove the sandbox from the local runqueue
//local runqueue
} }
done: done:
/* Cleanup connection and exit sandbox */ /* Cleanup connection and exit sandbox */

@ -177,7 +177,7 @@ listener_thread_main(void *dummy)
/* Allocate a Sandbox Request */ /* Allocate a Sandbox Request */
struct sandbox_request *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, (const struct sockaddr *)&client_address,
request_arrival_timestamp, work_admitted, NULL, 0); request_arrival_timestamp, work_admitted, NULL, 0);

Loading…
Cancel
Save