Repository: trafficserver
Updated Branches:
  refs/heads/5.2.x 7d2d30ba2 -> 88c7a20cd


TS-3140: Traffic Server asserts during response redirect.

Conflicts:
        CHANGES


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/88c7a20c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/88c7a20c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/88c7a20c

Branch: refs/heads/5.2.x
Commit: 88c7a20cd768cea0724b39b4237ea3cb26c9f54e
Parents: 7d2d30b
Author: shinrich <[email protected]>
Authored: Thu Jan 22 08:15:21 2015 -0600
Committer: Leif Hedstrom <[email protected]>
Committed: Tue Mar 24 15:23:19 2015 -0600

----------------------------------------------------------------------
 CHANGES                    |  2 ++
 proxy/InkAPI.cc            |  7 +++++--
 proxy/http/HttpSM.cc       | 24 ++++++++++++++++--------
 proxy/http/HttpTransact.cc |  3 ---
 proxy/http/HttpTransact.h  |  2 --
 proxy/http/HttpTunnel.cc   | 14 ++++++++++----
 6 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88c7a20c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 7898228..230cd7c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 5.2.1
 
+  *) [TS-3140] Traffic Server asserts during response redirect.
+
   *) [TS-3437] A null dhParams file will disable DHE.
 
   *) [TS-3424] SSL Failed: decryption failed or bad record mac.

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88c7a20c/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 62f0870..004eae4 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -4964,6 +4964,11 @@ TSHttpTxnSecondUrlTryLock(TSHttpTxn txnp)
   return TS_SUCCESS;
 }
 
+/*
+ * TSHttpTxnRedirectRequest is very odd.  It is only in experimental.h.  
+ * It is not used in any checked in code.  We should probably remove this.
+ * SKH 1/15/2015
+ */
 TSReturnCode
 TSHttpTxnRedirectRequest(TSHttpTxn txnp, TSMBuffer bufp, TSMLoc url_loc)
 {
@@ -4998,8 +5003,6 @@ TSHttpTxnRedirectRequest(TSHttpTxn txnp, TSMBuffer bufp, 
TSMLoc url_loc)
   r_url->copy(&u);
 
   s->hdr_info.server_request.destroy();
-  // we want to close the server session
-  s->api_release_server_session = true;
 
   s->request_sent_time = 0;
   s->response_received_time = 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88c7a20c/proxy/http/HttpSM.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 1c83409..6a239a5 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -1515,13 +1515,9 @@ HttpSM::handle_api_return()
   case HttpTransact::SM_ACTION_API_READ_CACHE_HDR:
   case HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR:
   case HttpTransact::SM_ACTION_API_CACHE_LOOKUP_COMPLETE:
-    // this part is added for automatic redirect
-    if (t_state.api_next_action == 
HttpTransact::SM_ACTION_API_READ_RESPONSE_HDR && 
t_state.api_release_server_session) {
-      t_state.api_release_server_session = false;
-      release_server_session();
-    } else if (t_state.api_next_action == 
HttpTransact::SM_ACTION_API_CACHE_LOOKUP_COMPLETE &&
-               t_state.api_cleanup_cache_read &&
-               t_state.api_update_cached_object != 
HttpTransact::UPDATE_CACHED_OBJECT_PREPARE) {
+    if (t_state.api_next_action == 
HttpTransact::SM_ACTION_API_CACHE_LOOKUP_COMPLETE &&
+        t_state.api_cleanup_cache_read &&
+        t_state.api_update_cached_object != 
HttpTransact::UPDATE_CACHED_OBJECT_PREPARE) {
       t_state.api_cleanup_cache_read = false;
       t_state.cache_info.object_read = NULL;
       t_state.request_sent_time = UNDEFINED_TIME;
@@ -1603,6 +1599,11 @@ HttpSM::handle_api_return()
 
   case HttpTransact::SM_ACTION_REDIRECT_READ:
     {
+      // Clean up from any communication with previous servers
+      release_server_session();
+      cache_sm.close_write();
+      //tunnel.deallocate_redirect_postdata_buffers();
+    
       call_transact_and_set_next_state(HttpTransact::HandleRequest);
       break;
     }
@@ -5075,6 +5076,7 @@ HttpSM::release_server_session(bool serve_from_cache)
   if (TS_SERVER_SESSION_SHARING_MATCH_NONE != 
t_state.txn_conf->server_session_sharing_match &&
       t_state.current.server->keep_alive == HTTP_KEEPALIVE &&
       t_state.hdr_info.server_response.valid() &&
+      t_state.hdr_info.server_request.valid() &&
       (t_state.hdr_info.server_response.status_get() == 
HTTP_STATUS_NOT_MODIFIED ||
        (t_state.hdr_info.server_request.method_get_wksidx() == HTTP_WKSIDX_HEAD
         && t_state.www_auth_content != HttpTransact::CACHE_AUTH_NONE)) &&
@@ -7616,8 +7618,10 @@ HttpSM::redirect_request(const char *redirect_url, const 
int redirect_len)
     valid_origHost = false;
 
   t_state.hdr_info.server_request.destroy();
+
   // we want to close the server session
-  t_state.api_release_server_session = true;
+  // will do that in handle_api_return under the 
+  // HttpTransact::SM_ACTION_REDIRECT_READ state
   t_state.parent_result.r = PARENT_UNDEFINED;
   t_state.request_sent_time = 0;
   t_state.response_received_time = 0;
@@ -7627,6 +7631,10 @@ HttpSM::redirect_request(const char *redirect_url, const 
int redirect_len)
   t_state.dns_info.lookup_success = false;
   t_state.force_dns = false;
 
+  if (t_state.txn_conf->cache_http) {
+    t_state.cache_info.object_read = NULL;
+  }
+
   bool noPortInHost = HttpConfig::m_master.redirection_host_no_port;
 
   // check to see if the client request passed a host header, if so copy the 
host and port from the redirect url and

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88c7a20c/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index fe65f81..db1291c 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -1243,9 +1243,6 @@ HttpTransact::HandleRequest(State* s)
     HTTP_INCREMENT_TRANS_STAT(https_incoming_requests_stat);
   }
 
-  if (s->api_release_server_session == true) {
-    s->api_release_server_session = false;
-  }
   ///////////////////////////////////////////////
   // if request is bad, return error response  //
   ///////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88c7a20c/proxy/http/HttpTransact.h
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index d55a0fb..d7d0973 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -969,7 +969,6 @@ public:
     // These ptrs are deallocate when transaction is over.
     HdrHeapSDKHandle *cache_req_hdr_heap_handle;
     HdrHeapSDKHandle *cache_resp_hdr_heap_handle;
-    bool api_release_server_session;
     bool api_cleanup_cache_read;
     bool api_server_response_no_store;
     bool api_server_response_ignore;
@@ -1082,7 +1081,6 @@ public:
         api_txn_no_activity_timeout_value(-1),
         cache_req_hdr_heap_handle(NULL),
         cache_resp_hdr_heap_handle(NULL),
-        api_release_server_session(false),
         api_cleanup_cache_read(false),
         api_server_response_no_store(false),
         api_server_response_ignore(false),

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88c7a20c/proxy/http/HttpTunnel.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
index ac89726..9462f01 100644
--- a/proxy/http/HttpTunnel.cc
+++ b/proxy/http/HttpTunnel.cc
@@ -1639,11 +1639,17 @@ 
HttpTunnel::allocate_redirect_postdata_buffers(IOBufferReader * ua_reader)
   // If fixed, obviously also fix the deallocator.
   if (postbuf == NULL) {
     postbuf = new PostDataBuffers();
+    postbuf->ua_buffer_reader = ua_reader;
+    postbuf->postdata_copy_buffer = new_MIOBuffer(alloc_index);
+    postbuf->postdata_copy_buffer_start = 
postbuf->postdata_copy_buffer->alloc_reader();
+    allocate_redirect_postdata_producer_buffer();
+  } else {
+    // Reset the buffer readers
+    
postbuf->postdata_copy_buffer->dealloc_reader(postbuf->postdata_copy_buffer_start);
+    postbuf->postdata_copy_buffer_start = 
postbuf->postdata_copy_buffer->alloc_reader();
+    
postbuf->postdata_producer_buffer->dealloc_reader(postbuf->postdata_producer_reader);
+    postbuf->postdata_producer_reader = 
postbuf->postdata_producer_buffer->alloc_reader();
   }
-  postbuf->ua_buffer_reader = ua_reader;
-  postbuf->postdata_copy_buffer = new_MIOBuffer(alloc_index);
-  postbuf->postdata_copy_buffer_start = 
postbuf->postdata_copy_buffer->alloc_reader();
-  allocate_redirect_postdata_producer_buffer();
 }
 
 

Reply via email to