From 30b03f609e9186bebeddb7f25dc8d1ff2822d7d0 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Tue, 20 Jul 2021 13:35:20 -0600 Subject: [PATCH 1/2] Make the rest of InkAPI allocators Proxy Allocated --- iocore/eventsystem/I_Thread.h | 4 ++++ src/traffic_server/InkAPI.cc | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/iocore/eventsystem/I_Thread.h b/iocore/eventsystem/I_Thread.h index 3c7905ba42c..91964b937a8 100644 --- a/iocore/eventsystem/I_Thread.h +++ b/iocore/eventsystem/I_Thread.h @@ -134,6 +134,10 @@ class Thread ProxyAllocator ioDataAllocator; ProxyAllocator ioAllocator; ProxyAllocator ioBlockAllocator; + // From InkAPI (plugins wrappers) + ProxyAllocator apiHookAllocator; + ProxyAllocator INKContAllocator; + ProxyAllocator INKVConnAllocator; ProxyAllocator mHandleAllocator; /** Start the underlying thread. diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index 7194ce72c28..179028ba1d0 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -1075,7 +1075,7 @@ INKContInternal::free() clear(); this->mutex.clear(); m_free_magic = INKCONT_INTERN_MAGIC_DEAD; - INKContAllocator.free(this); + THREAD_FREE(this, INKContAllocator, this_thread()); } void @@ -1181,7 +1181,7 @@ INKVConnInternal::free() clear(); this->mutex.clear(); m_free_magic = INKCONT_INTERN_MAGIC_DEAD; - INKVConnAllocator.free(this); + THREAD_FREE(this, INKVConnAllocator, this_thread()); } void @@ -1386,7 +1386,7 @@ APIHooks::append(INKContInternal *cont) { APIHook *api_hook; - api_hook = apiHookAllocator.alloc(); + api_hook = THREAD_ALLOC(apiHookAllocator, this_thread()); api_hook->m_cont = cont; m_hooks.enqueue(api_hook); @@ -1397,7 +1397,7 @@ APIHooks::clear() { APIHook *hook; while (nullptr != (hook = m_hooks.pop())) { - apiHookAllocator.free(hook); + THREAD_FREE(hook, apiHookAllocator, this_thread()); } } @@ -4599,7 +4599,7 @@ TSContCreate(TSEventFunc funcp, TSMutex mutexp) pluginThreadContext->acquire(); } - INKContInternal *i = INKContAllocator.alloc(); + INKContInternal *i = THREAD_ALLOC(INKContAllocator, this_thread()); i->init(funcp, mutexp, pluginThreadContext); return (TSCont)i; @@ -7002,7 +7002,7 @@ TSVConnCreate(TSEventFunc event_funcp, TSMutex mutexp) pluginThreadContext->acquire(); } - INKVConnInternal *i = INKVConnAllocator.alloc(); + INKVConnInternal *i = THREAD_ALLOC(INKVConnAllocator, this_thread()); sdk_assert(sdk_sanity_check_null_ptr((void *)i) == TS_SUCCESS); From 94638b16bf9ac785fa4447d785a56006e0edad67 Mon Sep 17 00:00:00 2001 From: Leif Hedstrom Date: Wed, 28 Jul 2021 14:12:05 -0600 Subject: [PATCH 2/2] As per Walt the all-knowing oracle, remove from test --- tests/tools/plugins/test_hooks.cc | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tests/tools/plugins/test_hooks.cc b/tests/tools/plugins/test_hooks.cc index 5f71a3ec7f1..176df3ee80b 100644 --- a/tests/tools/plugins/test_hooks.cc +++ b/tests/tools/plugins/test_hooks.cc @@ -344,30 +344,3 @@ TSPluginInit(int argc, const char *argv[]) tCont = TSContCreate(transactionContFunc, mtx); } - -namespace -{ -class Cleanup -{ -public: - ~Cleanup() - { - // In practice it is not strictly necessary to destroy remaining continuations on program exit. - - if (tCont) { - TSContDestroy(tCont); - } - if (sCont) { - TSContDestroy(sCont); - } - if (gCont) { - TSContDestroy(gCont); - } - } -}; - -// Do any needed cleanup for this source file at program termination time. -// -Cleanup cleanup; - -} // namespace