Skip to content

Commit

Permalink
Make the rest of InkAPI allocators Proxy Allocated (#8106)
Browse files Browse the repository at this point in the history
* Make the rest of InkAPI allocators Proxy Allocated

* As per Walt the all-knowing oracle, remove from test

(cherry picked from commit e6a7603)
  • Loading branch information
zwoop committed Jul 28, 2021
1 parent 8a8f1b7 commit 8116951
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 33 deletions.
4 changes: 4 additions & 0 deletions iocore/eventsystem/I_Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,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.
Expand Down
12 changes: 6 additions & 6 deletions src/traffic_server/InkAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ INKContInternal::free()
clear();
this->mutex.clear();
m_free_magic = INKCONT_INTERN_MAGIC_DEAD;
INKContAllocator.free(this);
THREAD_FREE(this, INKContAllocator, this_thread());
}

void
Expand Down Expand Up @@ -1180,7 +1180,7 @@ INKVConnInternal::free()
clear();
this->mutex.clear();
m_free_magic = INKCONT_INTERN_MAGIC_DEAD;
INKVConnAllocator.free(this);
THREAD_FREE(this, INKVConnAllocator, this_thread());
}

void
Expand Down Expand Up @@ -1385,7 +1385,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);
Expand All @@ -1396,7 +1396,7 @@ APIHooks::clear()
{
APIHook *hook;
while (nullptr != (hook = m_hooks.pop())) {
apiHookAllocator.free(hook);
THREAD_FREE(hook, apiHookAllocator, this_thread());
}
}

Expand Down Expand Up @@ -4598,7 +4598,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;
Expand Down Expand Up @@ -7069,7 +7069,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);

Expand Down
27 changes: 0 additions & 27 deletions tests/tools/plugins/test_hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8116951

Please sign in to comment.