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

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


The following commit(s) were added to refs/heads/9.2.x by this push:
     new 04bc7c99c Stabilize autest tls_hook18 (#9454)
04bc7c99c is described below

commit 04bc7c99c45c32601f8042b6d6550d65fec3582b
Author: Masakazu Kitajo <[email protected]>
AuthorDate: Mon Feb 27 12:41:11 2023 -0700

    Stabilize autest tls_hook18 (#9454)
    
    (cherry picked from commit 8c42dc4969b8284e4682d11ab2bb0b382de1964c)
---
 tests/gold_tests/tls_hooks/tls_hooks18.test.py |  2 +-
 tests/tools/plugins/ssl_hook_test.cc           | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/gold_tests/tls_hooks/tls_hooks18.test.py 
b/tests/gold_tests/tls_hooks/tls_hooks18.test.py
index 74994091f..20b92b812 100644
--- a/tests/gold_tests/tls_hooks/tls_hooks18.test.py
+++ b/tests/gold_tests/tls_hooks/tls_hooks18.test.py
@@ -51,7 +51,7 @@ ts.Disk.remap_config.AddLine(
     'map https://example.com:{1} 
http://127.0.0.1:{0}'.format(server.Variables.Port, ts.Variables.ssl_port)
 )
 
-Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 
'ssl_hook_test.so'), ts, '-client_hello=2')
+Test.PrepareTestPlugin(os.path.join(Test.Variables.AtsTestPluginsDir, 
'ssl_hook_test.so'), ts, '-client_hello=2 -close=1')
 
 tr = Test.AddTestRun("Test two client hello hooks")
 tr.Processes.Default.StartBefore(server)
diff --git a/tests/tools/plugins/ssl_hook_test.cc 
b/tests/tools/plugins/ssl_hook_test.cc
index 20be7822b..2adc1b4fc 100644
--- a/tests/tools/plugins/ssl_hook_test.cc
+++ b/tests/tools/plugins/ssl_hook_test.cc
@@ -35,9 +35,16 @@
 #define PN "ssl_hook_test"
 #define PCP "[" PN " Plugin] "
 
+static bool was_conn_closed;
+
 int
 ReenableSSL(TSCont cont, TSEvent event, void *edata)
 {
+  if (was_conn_closed) {
+    TSContDestroy(cont);
+    return TS_SUCCESS;
+  }
+
   TSVConn ssl_vc = reinterpret_cast<TSVConn>(TSContDataGet(cont));
   TSDebug(PN, "Callback reenable ssl_vc=%p", ssl_vc);
   TSVConnReenable(ssl_vc);
@@ -73,6 +80,7 @@ CB_Pre_Accept_Delay(TSCont cont, TSEvent event, void *edata)
   TSContDataSet(cb, ssl_vc);
 
   // Schedule to reenable in a bit
+  was_conn_closed = false;
   TSContScheduleOnPool(cb, 2000, TS_THREAD_POOL_NET);
 
   return TS_SUCCESS;
@@ -108,6 +116,7 @@ CB_out_start_delay(TSCont cont, TSEvent event, void *edata)
   TSContDataSet(cb, ssl_vc);
 
   // Schedule to reenable in a bit
+  was_conn_closed = false;
   TSContScheduleOnPool(cb, 2000, TS_THREAD_POOL_NET);
 
   return TS_SUCCESS;
@@ -124,6 +133,9 @@ CB_close(TSCont cont, TSEvent event, void *edata)
 
   // All done, reactivate things
   TSVConnReenable(ssl_vc);
+
+  was_conn_closed = true;
+
   return TS_SUCCESS;
 }
 
@@ -169,6 +181,7 @@ CB_Client_Hello(TSCont cont, TSEvent event, void *edata)
   TSContDataSet(cb, ssl_vc);
 
   // Schedule to reenable in a bit
+  was_conn_closed = false;
   TSContScheduleOnPool(cb, 2000, TS_THREAD_POOL_NET);
 
   return TS_SUCCESS;
@@ -215,6 +228,7 @@ CB_Cert(TSCont cont, TSEvent event, void *edata)
   TSContDataSet(cb, ssl_vc);
 
   // Schedule to reenable in a bit
+  was_conn_closed = false;
   TSContScheduleOnPool(cb, 2000, TS_THREAD_POOL_NET);
 
   return TS_SUCCESS;

Reply via email to