|
|
|
@ -71,7 +71,7 @@ current_sandbox_start(void)
|
|
|
|
|
|
|
|
|
|
sandbox_initialize_stdio(sandbox);
|
|
|
|
|
//struct module * next_module = sandbox->module->next_module;
|
|
|
|
|
struct module * next_module = sandbox->module->left_module;
|
|
|
|
|
struct module * next_module = sandbox->module->parent_module;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Add the client fd to epoll if it is the first or last sandbox in the chain because they
|
|
|
|
@ -84,7 +84,7 @@ current_sandbox_start(void)
|
|
|
|
|
if (sandbox->request_from_outside) {
|
|
|
|
|
if (sandbox_receive_request(sandbox) < 0) {
|
|
|
|
|
error_message = "Unable to receive or parse client request\n";
|
|
|
|
|
goto err;
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/*
|
|
|
|
@ -132,17 +132,37 @@ current_sandbox_start(void)
|
|
|
|
|
//uint64_t current_rs = enqueue_timestamp - system_start_timestamp;
|
|
|
|
|
//mem_log("time %lu request id:%d executing, name:%s remaining slack %lu\n", current_rs,
|
|
|
|
|
// sandbox->id, sandbox->module->name, sandbox->remaining_slack);
|
|
|
|
|
struct sandbox_request *sandbox_request =
|
|
|
|
|
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, enqueue_timestamp,
|
|
|
|
|
sandbox->remaining_slack, true, pre_func_output, output_length);
|
|
|
|
|
/* TODO: All sandboxs in the chain share the same request id, but sandbox_request_allocate()
|
|
|
|
|
* will busy-wait to generate an unique id, should we optimize it here?
|
|
|
|
|
*/
|
|
|
|
|
sandbox_request->id = sandbox->id;
|
|
|
|
|
#ifdef OPT_AVOID_GLOBAL_QUEUE
|
|
|
|
|
if (next_module->is_sandboxcreate == false)
|
|
|
|
|
{
|
|
|
|
|
if (strcpy(next_module->left_module->name, sandbox->module->name) == 0)
|
|
|
|
|
{
|
|
|
|
|
struct sandbox_request *sandbox_request =
|
|
|
|
|
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, enqueue_timestamp,
|
|
|
|
|
sandbox->remaining_slack, true, pre_func_output,NULL, output_length);
|
|
|
|
|
/* TODO: All sandboxs in the chain share the same request id, but sandbox_request_allocate()
|
|
|
|
|
* will busy-wait to generate an unique id, should we optimize it here?
|
|
|
|
|
*/
|
|
|
|
|
sandbox_request->id = sandbox->id;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
struct sandbox_request *sandbox_request =
|
|
|
|
|
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, enqueue_timestamp,
|
|
|
|
|
sandbox->remaining_slack, true, pre_func_output,NULL, output_length);
|
|
|
|
|
sandbox_request->id = sandbox->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*the first exed module creat next sandbox_request*/
|
|
|
|
|
next_module->parent_module->is_sandboxcreate == true;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
//此处需要两个任务:1.读取创建的父节点sandbox_request;2.是否合并上述两个节点的output作为一个input
|
|
|
|
|
#ifdef OPT_AVOID_GLOBAL_QUEUE
|
|
|
|
|
/* TODO: The running time of the current sandbox contains the next sandbox's initialization time, does it matter? */
|
|
|
|
|
if (sandbox->absolute_deadline == sandbox_request->absolute_deadline) {
|
|
|
|
|
/* Put the next sandbox to the local run queue to reduce the overhead of the global queue */
|
|
|
|
@ -167,6 +187,7 @@ current_sandbox_start(void)
|
|
|
|
|
sandbox_remove_from_epoll(sandbox);
|
|
|
|
|
}
|
|
|
|
|
sandbox_set_as_returned(sandbox, SANDBOX_RUNNING);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* Retrieve the result, construct the HTTP response, and send to client */
|
|
|
|
|
if (sandbox_send_response(sandbox) < 0) {
|
|
|
|
|