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

bcall pushed a commit to branch 7.0.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit d2e7ccd5c4e374d0a00cd746f492bd3ff2fbef27
Author: rb304g <rb3...@att.com>
AuthorDate: Thu Sep 29 18:42:56 2016 +0000

    TS-4911: ts_lua plugin is modified to clear 'client_response_hdrp' pointer 
when it enters SEND_RESPONSE_HDR hook.
    
    (cherry picked from commit 7662c30e48a444d0d8d37b2e2d34f71b21e3bfcd)
---
 plugins/experimental/ts_lua/ts_lua.c      | 7 +++++++
 plugins/experimental/ts_lua/ts_lua_util.c | 8 ++++++++
 2 files changed, 15 insertions(+)

diff --git a/plugins/experimental/ts_lua/ts_lua.c 
b/plugins/experimental/ts_lua/ts_lua.c
index 476c04a..11041dc 100644
--- a/plugins/experimental/ts_lua/ts_lua.c
+++ b/plugins/experimental/ts_lua/ts_lua.c
@@ -278,6 +278,13 @@ globalHookHandler(TSCont contp, TSEvent event ATS_UNUSED, 
void *edata)
     break;
 
   case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
+    // client response can be changed within a transaction
+    // (e.g. due to the follow redirect feature). So, clearing the pointers
+    // to allow API(s) to fetch the pointers again when it re-enters the hook
+    if (http_ctx->client_response_hdrp != NULL) {
+      TSHandleMLocRelease(http_ctx->client_response_bufp, TS_NULL_MLOC, 
http_ctx->client_response_hdrp);
+      http_ctx->client_response_hdrp = NULL;
+    }
     lua_getglobal(l, TS_LUA_FUNCTION_G_SEND_RESPONSE);
     break;
 
diff --git a/plugins/experimental/ts_lua/ts_lua_util.c 
b/plugins/experimental/ts_lua/ts_lua_util.c
index 4cfc9b8..b089d37 100644
--- a/plugins/experimental/ts_lua/ts_lua_util.c
+++ b/plugins/experimental/ts_lua/ts_lua_util.c
@@ -709,6 +709,14 @@ ts_lua_http_cont_handler(TSCont contp, TSEvent ev, void 
*edata)
 
   case TS_EVENT_HTTP_SEND_RESPONSE_HDR:
 
+    // client response can be changed within a transaction
+    // (e.g. due to the follow redirect feature). So, clearing the pointers
+    // to allow API(s) to fetch the pointers again when it re-enters the hook
+    if (http_ctx->client_response_hdrp != NULL) {
+      TSHandleMLocRelease(http_ctx->client_response_bufp, TS_NULL_MLOC, 
http_ctx->client_response_hdrp);
+      http_ctx->client_response_hdrp = NULL;
+    }
+
     lua_getglobal(L, TS_LUA_FUNCTION_SEND_RESPONSE);
 
     if (lua_type(L, -1) == LUA_TFUNCTION) {

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Reply via email to