do not monitor client fd with epoll if the sandbox is not the last one in the chain

main
xiaosuGW 3 years ago
parent a642082b73
commit 857c11d140

@ -145,6 +145,7 @@ sandbox_open_http(struct sandbox *sandbox)
/* Set the sandbox as the data the http-parser has access to */ /* Set the sandbox as the data the http-parser has access to */
sandbox->http_parser.data = sandbox; //assign data to sandbox in case to operator it when a callback happended sandbox->http_parser.data = sandbox; //assign data to sandbox in case to operator it when a callback happended
if (sandbox->module->next_module == NULL) {
/* Freshly allocated sandbox going runnable for first time, so register client socket with epoll */ /* Freshly allocated sandbox going runnable for first time, so register client socket with epoll */
struct epoll_event accept_evt; struct epoll_event accept_evt;
accept_evt.data.ptr = (void *)sandbox; accept_evt.data.ptr = (void *)sandbox;
@ -152,6 +153,7 @@ sandbox_open_http(struct sandbox *sandbox)
int rc = epoll_ctl(worker_thread_epoll_file_descriptor, EPOLL_CTL_ADD, sandbox->client_socket_descriptor, int rc = epoll_ctl(worker_thread_epoll_file_descriptor, EPOLL_CTL_ADD, sandbox->client_socket_descriptor,
&accept_evt); &accept_evt);
if (unlikely(rc < 0)) panic_err(); if (unlikely(rc < 0)) panic_err();
}
} }
/** /**

@ -88,7 +88,7 @@ sandbox_receive_request(struct sandbox *sandbox)
sandbox->request_response_data_length += nparsed; sandbox->request_response_data_length += nparsed;
} }
http_request_print(&sandbox->http_request);
sandbox->request_length = sandbox->request_response_data_length; sandbox->request_length = sandbox->request_response_data_length;
rc = 0; rc = 0;

@ -24,7 +24,6 @@ worker_thread_execute_epoll_loop(void)
struct epoll_event epoll_events[RUNTIME_MAX_EPOLL_EVENTS]; struct epoll_event epoll_events[RUNTIME_MAX_EPOLL_EVENTS];
int descriptor_count = epoll_wait(worker_thread_epoll_file_descriptor, epoll_events, int descriptor_count = epoll_wait(worker_thread_epoll_file_descriptor, epoll_events,
RUNTIME_MAX_EPOLL_EVENTS, 0); RUNTIME_MAX_EPOLL_EVENTS, 0);
if (descriptor_count < 0) { if (descriptor_count < 0) {
if (errno == EINTR) continue; if (errno == EINTR) continue;

@ -116,11 +116,7 @@ current_sandbox_start(void)
sandbox->request_arrival_timestamp, true, pre_func_output, output_length); sandbox->request_arrival_timestamp, true, pre_func_output, output_length);
/* Add to the Global Sandbox Request Scheduler */ /* Add to the Global Sandbox Request Scheduler */
global_request_scheduler_add(sandbox_request); global_request_scheduler_add(sandbox_request);
sandbox_remove_from_epoll(sandbox);
sandbox_set_as_returned(sandbox, SANDBOX_RUNNING); sandbox_set_as_returned(sandbox, SANDBOX_RUNNING);
scheduler_yield();
assert(0);
return;
} 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

Loading…
Cancel
Save