!1943 Fixes a minor leak in MOT masstree index
Merge pull request !1943 from Vinoth Veeraraghavan/master
This commit is contained in:
@ -54,13 +54,27 @@ inline threadinfo::threadinfo(int purpose, int index, int rcu_max_free_count)
|
||||
ts_ = 2;
|
||||
}
|
||||
|
||||
// if rcu_max_free_count == -1, destroy threadinfo structure
|
||||
threadinfo* threadinfo::make(void* obj_mem, int purpose, int index, int rcu_max_free_count)
|
||||
{
|
||||
threadinfo* ti = new (obj_mem) threadinfo(purpose, index, rcu_max_free_count);
|
||||
if (rcu_max_free_count == -1) {
|
||||
// act as destructor
|
||||
MOT_ASSERT(obj_mem);
|
||||
threadinfo* ti = (threadinfo*)obj_mem;
|
||||
masstree_invariant(ti->dealloc_rcu.size() == 0);
|
||||
delete ti;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
threadinfo* ti = new (std::nothrow) threadinfo(purpose, index, rcu_max_free_count);
|
||||
if (ti == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (use_pool()) {
|
||||
void* limbo_space = ti->allocate(MAX_MEMTAG_MASSTREE_LIMBO_GROUP_ALLOCATION_SIZE, memtag_limbo);
|
||||
if (!limbo_space) {
|
||||
delete ti;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -95,13 +95,14 @@ extern void ClearCurrentNumaNodeId()
|
||||
extern bool InitMasstreeThreadinfo()
|
||||
{
|
||||
if (mtSessionThreadInfo == nullptr) {
|
||||
mtSessionThreadInfo = (threadinfo*)malloc(sizeof(threadinfo));
|
||||
|
||||
MOT_LOG_TRACE("InitMasstreeThreadinfo(): Create mtSessionThreadInfo %p. MOTCurrThreadId: %u\n",
|
||||
mtSessionThreadInfo,
|
||||
MOTCurrThreadId);
|
||||
mtSessionThreadInfo =
|
||||
threadinfo::make(mtSessionThreadInfo, threadinfo::TI_PROCESS, MOTCurrThreadId, 0 /* Create object */);
|
||||
if (mtSessionThreadInfo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mtSessionThreadInfo = threadinfo::make(mtSessionThreadInfo, threadinfo::TI_PROCESS, MOTCurrThreadId, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -109,7 +110,11 @@ extern bool InitMasstreeThreadinfo()
|
||||
extern void DestroyMasstreeThreadinfo()
|
||||
{
|
||||
if (mtSessionThreadInfo != nullptr) {
|
||||
free(mtSessionThreadInfo);
|
||||
MOT_LOG_TRACE("DestroyMasstreeThreadinfo(): Destroy mtSessionThreadInfo %p. MOTCurrThreadId: %u\n",
|
||||
mtSessionThreadInfo,
|
||||
MOTCurrThreadId);
|
||||
|
||||
threadinfo::make(mtSessionThreadInfo, threadinfo::TI_PROCESS, MOTCurrThreadId, -1 /* Destroy object */);
|
||||
mtSessionThreadInfo = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user