You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/03/30 14:57:51 UTC
[trafficserver] branch 7.1.x updated: Set
HttpSM::tunnel_handler_post to handle write event for outputing HTTP 408
response.
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/7.1.x by this push:
new 25a08be Set HttpSM::tunnel_handler_post to handle write event for outputing HTTP 408 response.
25a08be is described below
commit 25a08befe8598345dc4e2813c626b19a30eaddb3
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Wed Mar 15 16:31:31 2017 +0800
Set HttpSM::tunnel_handler_post to handle write event for outputing HTTP 408 response.
If POST transform plugin does not finished before the ua_session
timeouted, the producer will received a TIMEOUT event and callback
producer_handler (HttpSM::tunnel_handler_post_ua).
The HttpSM::tunnel_handler_post_ua will send a 408 response to client.
The ua_session will received TIMEOUT event again in the next second
because it does not reset the ua_session's timeout.
The TIMEOUT event will be sent to HttpSM default handler because we did
not save VIO returned by do_io_write to ua_entry->write_vio.
The default handler is HttpSM::state_request_wait_for_transform_read and
the TIMEOUT event is unexpected, then ink_release_asserti(0) at L1333
(at the end of HttpSM::state_common_wait_for_transform_read).
In HttpSM::tunnel_handler_post(), calling tunnel_handler_post_or_put(p)
before vc_table.cleanup_all() and tunnel.chain_abort_all(p).
(cherry picked from commit 7335d7c5d7e9a37f84f1ae24e039194fb59b0d4a)
---
proxy/http/HttpSM.cc | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index c74d888..b5f3269 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -2751,25 +2751,39 @@ HttpSM::tunnel_handler_post(int event, void *data)
return 0; // Cannot do anything if there is no producer
}
- if (event != HTTP_TUNNEL_EVENT_DONE) {
- if ((event == VC_EVENT_WRITE_COMPLETE) || (event == VC_EVENT_EOS)) {
- if (ua_entry->write_buffer) {
- free_MIOBuffer(ua_entry->write_buffer);
- ua_entry->write_buffer = nullptr;
- }
- }
+ switch (event) {
+ case HTTP_TUNNEL_EVENT_DONE: // Tunnel done.
+ break;
+ case VC_EVENT_WRITE_READY: // iocore may callback first before send.
+ return 0;
+ case VC_EVENT_EOS: // SSLNetVC may callback EOS during write error (6.0.x or early)
+ case VC_EVENT_ERROR: // Send HTTP 408 error
+ case VC_EVENT_WRITE_COMPLETE: // tunnel_handler_post_ua has sent HTTP 408 response
+ case VC_EVENT_INACTIVITY_TIMEOUT: // ua_session timeout during sending the HTTP 408 response
+ case VC_EVENT_ACTIVE_TIMEOUT: // ua_session timeout
+ if (ua_entry->write_buffer) {
+ free_MIOBuffer(ua_entry->write_buffer);
+ ua_entry->write_buffer = nullptr;
+ ua_entry->vc->do_io_write(this, 0, NULL);
+ }
+ // The if statement will always true since these codes are all for HTTP 408 response sending. - by oknet xu
if (p->handler_state == HTTP_SM_POST_UA_FAIL) {
Debug("http_tunnel", "cleanup tunnel in tunnel_handler_post");
hsm_release_assert(ua_entry->in_tunnel == true);
- ink_assert((event == VC_EVENT_WRITE_COMPLETE) || (event == VC_EVENT_EOS));
+ tunnel_handler_post_or_put(p);
vc_table.cleanup_all();
tunnel.chain_abort_all(p);
p->read_vio = nullptr;
p->vc->do_io_close(EHTTP_ERROR);
- tunnel_handler_post_or_put(p);
tunnel.kill_tunnel();
return 0;
}
+ break;
+ case VC_EVENT_READ_READY:
+ case VC_EVENT_READ_COMPLETE:
+ default:
+ ink_assert(!"not reached");
+ return 0;
}
ink_assert(event == HTTP_TUNNEL_EVENT_DONE);
@@ -3501,7 +3515,12 @@ HttpSM::tunnel_handler_post_ua(int event, HttpTunnelProducer *p)
nbytes = ua_entry->write_buffer->write(str_408_request_timeout_response, len_408_request_timeout_response);
nbytes += ua_entry->write_buffer->write(t_state.internal_msg_buffer, t_state.internal_msg_buffer_size);
- p->vc->do_io_write(this, nbytes, buf_start);
+ // The HttpSM default handler still is HttpSM::state_request_wait_for_transform_read.
+ // However, WRITE_COMPLETE/TIMEOUT/ERROR event should be managed/handled by tunnel_handler_post.
+ ua_entry->vc_handler = &HttpSM::tunnel_handler_post;
+ ua_entry->write_vio = p->vc->do_io_write(this, nbytes, buf_start);
+ // Reset the inactivity timeout, otherwise the InactivityCop will callback again in the next second.
+ ua_session->set_inactivity_timeout(HRTIME_SECONDS(t_state.txn_conf->transaction_no_activity_timeout_in));
p->vc->do_io_shutdown(IO_SHUTDOWN_READ);
return 0;
}
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].