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 2020/05/14 16:55:39 UTC

[trafficserver] branch 9.0.x updated: Fix crash when folloing redirect

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new b72c859  Fix crash when folloing redirect
b72c859 is described below

commit b72c8597757f0e93d3d5c080d56115ec1afefed9
Author: YuanYingdong <19...@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.
    
    (cherry picked from commit 36ebb2d2a5cfdf794ea2661ed5f6e55090918d81)
---
 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 9ec1d73..0065775 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7843,10 +7843,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 a0e8ed5..8bfa521 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -2088,7 +2088,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 {