Repository: trafficserver Updated Branches: refs/heads/master 514c9e1a6 -> 42416b3f4
TS-3084: Fix FIN forward on POST. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/42416b3f Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/42416b3f Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/42416b3f Branch: refs/heads/master Commit: 42416b3f48c87bd57093f2ce8ce5ece8dae6ca22 Parents: 514c9e1 Author: Susan Hinrichs <[email protected]> Authored: Sun Sep 21 20:39:16 2014 -0500 Committer: Alan M. Carroll <[email protected]> Committed: Sun Sep 21 20:41:18 2014 -0500 ---------------------------------------------------------------------- CHANGES | 4 ++++ proxy/http/HttpClientSession.cc | 2 +- proxy/http/HttpSM.cc | 13 +++++++++++++ proxy/http/HttpTunnel.cc | 9 +++++++-- 4 files changed, 25 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42416b3f/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index b401177..866ac29 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,11 @@ -*- coding: utf-8 -*- Changes with Apache Traffic Server 5.2.0 + *) [TS-3084] Fix FIN forwarding issue with POST. + Author: Susan Hinrichs <[email protected]> + *) [TS-3073] Fix FIN forwarding issue with transparent pass-through. + Author: Susan Hinrichs <[email protected]> *) [TS-3059] Add the TSTextLogObjectRollingSizeMbSet API function. Author: Brian Rectanus <[email protected]> http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42416b3f/proxy/http/HttpClientSession.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpClientSession.cc b/proxy/http/HttpClientSession.cc index c4d1a30..57991de 100644 --- a/proxy/http/HttpClientSession.cc +++ b/proxy/http/HttpClientSession.cc @@ -264,7 +264,7 @@ HttpClientSession::do_io_close(int alerrno) slave_ka_vio = NULL; } - if (half_close) { + if (half_close && this->current_reader) { read_state = HCS_HALF_CLOSED; SET_HANDLER(&HttpClientSession::state_wait_for_close); DebugHttpSsn("[%" PRId64 "] session half close", con_id); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42416b3f/proxy/http/HttpSM.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 3dde3c3..29d92f7 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -847,7 +847,14 @@ HttpSM::state_watch_for_client_abort(int event, void *data) ink_assert(ua_entry->vc == ua_session); switch (event) { + /* EOS means that the client has initiated the connection shut down. + * Only half close the client connection so ATS can read additional + * data that may still be sent from the server and send it to the + * client. + */ case VC_EVENT_EOS: + static_cast<HttpClientSession*>(ua_entry->vc)->get_netvc()->do_io_shutdown(IO_SHUTDOWN_READ); + break; case VC_EVENT_ERROR: case VC_EVENT_ACTIVE_TIMEOUT: case VC_EVENT_INACTIVITY_TIMEOUT: @@ -5358,6 +5365,12 @@ HttpSM::do_setup_post_tunnel(HttpVC_t to_vc_type) tunnel.set_producer_chunking_action(p, 0, TCA_PASSTHRU_CHUNKED_CONTENT); tunnel.tunnel_run(p); + + // If we're half closed, we got a FIN from the client. Forward it on to the origin server + // now that we have the tunnel operational. + if (ua_session->get_half_close_flag()) { + p->vc->do_io_shutdown(IO_SHUTDOWN_READ); + } } // void HttpSM::perform_transform_cache_write_action() http://git-wip-us.apache.org/repos/asf/trafficserver/blob/42416b3f/proxy/http/HttpTunnel.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc index d7f362c..f6f77c8 100644 --- a/proxy/http/HttpTunnel.cc +++ b/proxy/http/HttpTunnel.cc @@ -896,9 +896,14 @@ HttpTunnel::producer_run(HttpTunnelProducer * p) // set the amount to read since we know it. We will send the FIN // to the server on VC_EVENT_WRITE_COMPLETE. if (p->vc_type == HT_HTTP_CLIENT) { - if (static_cast<HttpClientSession *>(p->vc)->get_half_close_flag()) { + HttpClientSession* ua_vc = static_cast<HttpClientSession*>(p->vc); + if (ua_vc->get_half_close_flag() || producer_n == 0) { + // Force the half close to make sure we send the FIN immediately after we finish writing. + ua_vc->set_half_close_flag(); c_write = c->buffer_reader->read_avail(); - p->alive = false; + if (producer_n != 0) { + p->alive = false; + } } }
