ywkaras commented on a change in pull request #6800:
URL: https://github.com/apache/trafficserver/pull/6800#discussion_r427426715



##########
File path: src/tscpp/api/utils_internal.cc
##########
@@ -49,6 +49,25 @@ resetTransactionHandles(Transaction &transaction, TSEvent 
event)
   return;
 }
 
+void
+cleanupTransaction(Transaction &transaction, TSHttpTxn ats_txn_handle)
+{
+  delete &transaction;
+  // reset the txn arg to prevent use-after-free
+  TSUserArgSet(ats_txn_handle, TRANSACTION_STORAGE_INDEX, nullptr);
+}
+
+void
+cleanupTransactionPlugin(Plugin *plugin)
+{
+  TransactionPlugin *transaction_plugin = static_cast<TransactionPlugin 
*>(plugin);
+  std::shared_ptr<Mutex> trans_mutex    = 
utils::internal::getTransactionPluginMutex(*transaction_plugin);
+  LOG_DEBUG("Locking TransactionPlugin mutex to delete transaction plugin at 
%p", transaction_plugin);
+  trans_mutex->lock();

Review comment:
       I think maybe you just wanna call 
transaction_plugin->handleTxnClose(transaction) right here and not call it in 
invokePluginForEvent().  You'd add a little overhead to transactions not using 
this hook, but it's unlikely to be an issue.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to