Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for 6.2.0-rc2 #86

Open
wants to merge 2 commits into
base: origin-6.2.0-rc2-1733941139
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions proxy/http/HttpDebugNames.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,6 @@ HttpDebugNames::get_action_name(HttpTransact::StateMachineAction_t e)
case HttpTransact::SM_ACTION_TRANSFORM_READ:
return ("SM_ACTION_TRANSFORM_READ");

#ifdef PROXY_DRAIN
case HttpTransact::SM_ACTION_DRAIN_REQUEST_BODY:
return ("SM_ACTION_DRAIN_REQUEST_BODY");
#endif /* PROXY_DRAIN */

case HttpTransact::SM_ACTION_API_SM_START:
return ("SM_ACTION_API_SM_START");
case HttpTransact::SM_ACTION_REDIRECT_READ:
Expand Down
103 changes: 23 additions & 80 deletions proxy/http/HttpSM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -823,63 +823,6 @@ HttpSM::state_read_client_request_header(int event, void *data)
return 0;
}

#ifdef PROXY_DRAIN
int
HttpSM::state_drain_client_request_body(int event, void *data)
{
STATE_ENTER(&HttpSM::state_drain_client_request_body, event);

ink_assert(ua_entry->read_vio == (VIO *)data);
ink_assert(ua_entry->vc == ua_session);

NetVConnection *netvc = ua_session->get_netvc();
if (!netvc && event != VC_EVENT_EOS)
return 0;

switch (event) {
case VC_EVENT_EOS:
case VC_EVENT_ERROR:
case VC_EVENT_ACTIVE_TIMEOUT:
case VC_EVENT_INACTIVITY_TIMEOUT: {
// Nothing we can do
terminate_sm = true;
break;
}
case VC_EVENT_READ_READY: {
int64_t avail = ua_buffer_reader->read_avail();
int64_t left = t_state.hdr_info.request_content_length - client_request_body_bytes;

// Since we are only reading what's needed to complete
// the post, there must be something left to do
ink_assert(avail < left);

client_request_body_bytes += avail;
ua_buffer_reader->consume(avail);
ua_entry->read_vio->reenable_re();
break;
}
case VC_EVENT_READ_COMPLETE: {
// We've finished draing the POST body
int64_t avail = ua_buffer_reader->read_avail();

ua_buffer_reader->consume(avail);
client_request_body_bytes += avail;
ink_assert(client_request_body_bytes == t_state.hdr_info.request_content_length);

ua_buffer_reader->mbuf->size_index = HTTP_HEADER_BUFFER_SIZE_INDEX;
ua_entry->vc_handler = &HttpSM::state_watch_for_client_abort;
ua_entry->read_vio = ua_entry->vc->do_io_read(this, INT64_MAX, ua_buffer_reader->mbuf);
call_transact_and_set_next_state(NULL);
break;
}
default:
ink_release_assert(0);
}

return EVENT_DONE;
}
#endif /* PROXY_DRAIN */

int
HttpSM::state_watch_for_client_abort(int event, void *data)
{
Expand Down Expand Up @@ -5505,29 +5448,34 @@ HttpSM::setup_transform_to_server_transfer()
tunnel.tunnel_run(p);
}

#ifdef PROXY_DRAIN
void
HttpSM::do_drain_request_body()
{
int64_t post_bytes = t_state.hdr_info.request_content_length;
int64_t avail = ua_buffer_reader->read_avail();
int64_t content_length = t_state.hdr_info.client_request.get_content_length();
int64_t avail = ua_buffer_reader->read_avail();

int64_t act_on = (avail < post_bytes) ? avail : post_bytes;

client_request_body_bytes = act_on;
ua_buffer_reader->consume(act_on);

ink_assert(client_request_body_bytes <= post_bytes);
if (t_state.client_info.transfer_encoding == HttpTransact::CHUNKED_ENCODING) {
Debug("http", "Chunked body, setting the response to non-keepalive");
goto close_connection;
}

if (client_request_body_bytes < post_bytes) {
ua_buffer_reader->mbuf->size_index = buffer_size_to_index(t_state.hdr_info.request_content_length);
ua_entry->vc_handler = &HttpSM::state_drain_client_request_body;
ua_entry->read_vio = ua_entry->vc->do_io_read(this, post_bytes - client_request_body_bytes, ua_buffer_reader->mbuf);
} else {
call_transact_and_set_next_state(NULL);
if (content_length > 0) {
if (avail >= content_length) {
Debug("http", "entire body is in the buffer, consuming");
int64_t act_on = (avail < content_length) ? avail : content_length;
client_request_body_bytes = act_on;
ua_buffer_reader->consume(act_on);
} else {
Debug("http", "entire body is not in the buffer, setting the response to non-keepalive");
goto close_connection;
}
}
return;

close_connection:
t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE;
t_state.hdr_info.client_response.value_set(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION, "close", 5);
}
#endif /* PROXY_DRAIN */

void
HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type)
Expand Down Expand Up @@ -7316,6 +7264,8 @@ HttpSM::set_next_state()
release_server_session(true);
t_state.source = HttpTransact::SOURCE_CACHE;

do_drain_request_body();

if (transform_info.vc) {
ink_assert(t_state.hdr_info.client_response.valid() == 0);
ink_assert((t_state.hdr_info.transform_response.valid() ? true : false) == true);
Expand Down Expand Up @@ -7506,13 +7456,6 @@ HttpSM::set_next_state()
break;
}

#ifdef PROXY_DRAIN
case HttpTransact::SM_ACTION_DRAIN_REQUEST_BODY: {
do_drain_request_body();
break;
}
#endif /* PROXY_DRAIN */

case HttpTransact::SM_ACTION_CONTINUE: {
ink_release_assert(!"Not implemented");
}
Expand Down
Loading