This is an automated email from the ASF dual-hosted git repository. scw00 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push: new 36ebb2d Fix crash when folloing redirect 36ebb2d is described below commit 36ebb2d2a5cfdf794ea2661ed5f6e55090918d81 Author: YuanYingdong <1975643...@qq.com> AuthorDate: Wed Mar 25 20:45:10 2020 +0800 Fix crash when folloing redirect When doing redirect and get cache read miss, we need to get cache write lock first other than directly do cache write directly. --- proxy/http/HttpSM.cc | 7 +++---- proxy/http/HttpTransact.cc | 7 ++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 9b14343..1bf7500 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -7859,10 +7859,9 @@ HttpSM::redirect_request(const char *arg_redirect_url, const int arg_redirect_le // will do that in handle_api_return under the // HttpTransact::SM_ACTION_REDIRECT_READ state t_state.parent_result.reset(); - t_state.request_sent_time = 0; - t_state.response_received_time = 0; - t_state.cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT; - t_state.next_action = HttpTransact::SM_ACTION_REDIRECT_READ; + t_state.request_sent_time = 0; + t_state.response_received_time = 0; + t_state.next_action = HttpTransact::SM_ACTION_REDIRECT_READ; // we have a new OS and need to have DNS lookup the new OS t_state.dns_info.lookup_success = false; t_state.force_dns = false; diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index b62fcc2..026870a 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -2106,7 +2106,12 @@ HttpTransact::DecideCacheLookup(State *s) if (s->redirect_info.redirect_in_process) { // without calling out the CACHE_LOOKUP_COMPLETE_HOOK if (s->txn_conf->cache_http) { - s->cache_info.action = CACHE_DO_WRITE; + if (s->cache_info.write_lock_state == CACHE_WL_FAIL) { + s->cache_info.action = CACHE_PREPARE_TO_WRITE; + s->cache_info.write_lock_state = HttpTransact::CACHE_WL_INIT; + } else if (s->cache_info.write_lock_state == CACHE_WL_SUCCESS) { + s->cache_info.action = CACHE_DO_WRITE; + } } LookupSkipOpenServer(s); } else {