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

shinrich 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 7eaefc9  Fix MLoc assert caused by s3auth (#7790)
7eaefc9 is described below

commit 7eaefc923014e2e3808abcd89433640ce0a41d54
Author: Susan Hinrichs <[email protected]>
AuthorDate: Tue May 11 10:10:07 2021 -0500

    Fix MLoc assert caused by s3auth (#7790)
---
 plugins/s3_auth/s3_auth.cc | 54 +++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/plugins/s3_auth/s3_auth.cc b/plugins/s3_auth/s3_auth.cc
index 5b381ab..d8d8244 100644
--- a/plugins/s3_auth/s3_auth.cc
+++ b/plugins/s3_auth/s3_auth.cc
@@ -991,36 +991,40 @@ S3Request::authorizeV2(S3Config *s3)
 int
 event_handler(TSCont cont, TSEvent event, void *edata)
 {
-  TSHttpTxn txnp = static_cast<TSHttpTxn>(edata);
-  S3Config *s3   = static_cast<S3Config *>(TSContDataGet(cont));
-
-  S3Request request(txnp);
-  TSHttpStatus status  = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
+  TSHttpTxn txnp       = static_cast<TSHttpTxn>(edata);
+  S3Config *s3         = static_cast<S3Config *>(TSContDataGet(cont));
   TSEvent enable_event = TS_EVENT_HTTP_CONTINUE;
 
-  switch (event) {
-  case TS_EVENT_HTTP_SEND_REQUEST_HDR:
-    if (request.initialize()) {
-      while (s3->reload_waiting) {
-        std::this_thread::yield();
-      }
+  {
+    S3Request request(txnp);
+    TSHttpStatus status = TS_HTTP_STATUS_INTERNAL_SERVER_ERROR;
 
-      std::shared_lock lock(s3->reload_mutex);
-      status = request.authorize(s3);
-    }
+    switch (event) {
+    case TS_EVENT_HTTP_SEND_REQUEST_HDR:
+      if (request.initialize()) {
+        while (s3->reload_waiting) {
+          std::this_thread::yield();
+        }
 
-    if (TS_HTTP_STATUS_OK == status) {
-      TSDebug(PLUGIN_NAME, "Successfully signed the AWS S3 URL");
-    } else {
-      TSDebug(PLUGIN_NAME, "Failed to sign the AWS S3 URL, status = %d", 
status);
-      TSHttpTxnStatusSet(txnp, status);
-      enable_event = TS_EVENT_HTTP_ERROR;
+        std::shared_lock lock(s3->reload_mutex);
+        status = request.authorize(s3);
+      }
+
+      if (TS_HTTP_STATUS_OK == status) {
+        TSDebug(PLUGIN_NAME, "Successfully signed the AWS S3 URL");
+      } else {
+        TSDebug(PLUGIN_NAME, "Failed to sign the AWS S3 URL, status = %d", 
status);
+        TSHttpTxnStatusSet(txnp, status);
+        enable_event = TS_EVENT_HTTP_ERROR;
+      }
+      break;
+    default:
+      TSError("[%s] Unknown event for this plugin", PLUGIN_NAME);
+      TSDebug(PLUGIN_NAME, "unknown event for this plugin");
+      break;
     }
-    break;
-  default:
-    TSError("[%s] Unknown event for this plugin", PLUGIN_NAME);
-    TSDebug(PLUGIN_NAME, "unknown event for this plugin");
-    break;
+    // Most get S3Request out of scope in case the later plugins invalidate 
the TSAPI
+    // objects it references.  Some cases were causing asserts from the 
destructor
   }
 
   TSHttpTxnReenable(txnp, enable_event);

Reply via email to