diff --git a/Control/L3MMLayer.cpp b/Control/L3MMLayer.cpp index 7a0b8e3..d259291 100644 --- a/Control/L3MMLayer.cpp +++ b/Control/L3MMLayer.cpp @@ -251,8 +251,9 @@ void MMUser::mmuFree(MMUserMap::iterator *piter, TermCause cause) // Some caller LOG(DEBUG) << "MMUser DELETE "<<(void*)this <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) <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(this)); if (mContext) { mContext->mmDisconnectTran(this); } // DANGER: this deletes the transaction as a side effect.