Fix TranEntry double deletion introduced by previous commit f93c48.

This commit is contained in:
pat
2014-10-10 10:37:35 -07:00
committed by Michael Iedema
parent c0cd4b778e
commit af0221fab4
2 changed files with 8 additions and 3 deletions

View File

@@ -251,8 +251,9 @@ void MMUser::mmuFree(MMUserMap::iterator *piter, TermCause cause) // Some caller
LOG(DEBUG) << "MMUser DELETE "<<(void*)this <<LOGVAR(!!piter);
// At this point the only pointer to the transaction is in the InterthreadQueue.
// Once the transaction moves to the MMContext it will be put in a RefCntPointer.
while (TranEntry *tran = mmuMTCq.pop_frontr()) { tran->teCancel(cause); delete tran; }
while (TranEntry *tran = mmuMTSMSq.pop_frontr()) { tran->teCancel(cause); delete tran; }
// 10-10-2014: Formerly we needed to delete tran here, but now it is done inside teCancel.
while (TranEntry *tran = mmuMTCq.pop_frontr()) { tran->teCancel(cause); }
while (TranEntry *tran = mmuMTSMSq.pop_frontr()) { tran->teCancel(cause); }
if (piter) { // It is just an efficiency issue to use the iterator if we already have one.
gMMLayer.MMUsers.erase(*piter);
@@ -1203,7 +1204,7 @@ MMUser *MMLayer::mmFindByMobileId(L3MobileIdentity&mid)
// When called from the paging thread loop this function is responsible for noticing expired MMUsers and deleting them.
void MMLayer::mmGetPages(NewPagingList_t &pages)
{
//LOG(DEBUG) <<LOGVAR(MMUsers.size());
LOG(DEBUG) <<"before "<<LOGVAR(MMUsers.size());
assert(pages.size() == 0); // Caller passes us a new list each time.
@@ -1235,6 +1236,7 @@ void MMLayer::mmGetPages(NewPagingList_t &pages)
pages.push_back(tmp);
}
}
LOG(DEBUG) <<"after "<<LOGVAR(MMUsers.size());
if (pages.size()) LOG(DEBUG) <<LOGVAR(pages.size());
}

View File

@@ -1638,6 +1638,9 @@ void TranEntry::teRemove(TermCause cause)
delete this->tePopMachine();
}
// If the TranEntry never got into an MMContext, ie, deleted from MMUser::MMFree, this is the first time it has been
// put under RefCntPointer control - from this point on it will be deleted when the last reference count disappears,
// which is the pop_front out of the sDeletedTranEntrys below.
sDeletedTranEntrys.push_back(RefCntPointer<TranEntry>(this));
if (mContext) { mContext->mmDisconnectTran(this); } // DANGER: this deletes the transaction as a side effect.