void _pmdEDUCB::releaseBuff( CHAR *pBuff ) { ALLOC_MAP_IT itAlloc = _allocMap.find( pBuff ) ; if ( itAlloc == _allocMap.end() ) { SDB_OSS_FREE( pBuff ) ; return ; } INT32 buffLen = itAlloc->second ; _allocMap.erase( itAlloc ) ; if ( (UINT32)buffLen > EDU_MAX_CATCH_SIZE ) { SDB_OSS_FREE( pBuff ) ; _totalMemSize -= buffLen ; } else { _catchMap.insert( std::make_pair( buffLen, pBuff ) ) ; _totalCatchSize += buffLen ; while ( _totalCatchSize > EDU_MAX_CATCH_SIZE ) { CATCH_MAP_IT it = _catchMap.begin() ; SDB_OSS_FREE( it->second ) ; _totalMemSize -= it->first ; _totalCatchSize -= it->first ; _catchMap.erase( it ) ; } } }
void _pmdEDUCB::clear() { pmdEDUEvent data ; while ( _queue.try_pop( data ) ) { pmdEduEventRelase( data, this ) ; } _processEventCount = 0 ; _Name[0] = 0 ; _userName = "" ; _passWord = "" ; #if defined ( SDB_ENGINE ) clearTransInfo() ; releaseAlignedMemory() ; resetLsn() ; #endif // SDB_ENGINE if ( _pCompressBuff ) { releaseBuff( _pCompressBuff ) ; _pCompressBuff = NULL ; } _compressBuffLen = 0 ; if ( _pUncompressBuff ) { releaseBuff( _pUncompressBuff ) ; _pUncompressBuff = NULL ; } _uncompressBuffLen = 0 ; CATCH_MAP_IT it = _catchMap.begin() ; while ( it != _catchMap.end() ) { SDB_OSS_FREE( it->second ) ; _totalCatchSize -= it->first ; _totalMemSize -= it->first ; ++it ; } _catchMap.clear() ; ALLOC_MAP_IT itAlloc = _allocMap.begin() ; while ( itAlloc != _allocMap.end() ) { SDB_OSS_FREE( itAlloc->first ) ; _totalMemSize -= itAlloc->second ; ++itAlloc ; } _allocMap.clear() ; SDB_ASSERT( _totalCatchSize == 0 , "Catch size is error" ) ; SDB_ASSERT( _totalMemSize == 0, "Memory size is error" ) ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__CLSCATCLR_CALL, "_clsCatalogCaller::call" ) INT32 _clsCatalogCaller::call( MsgHeader *header ) { SDB_ASSERT( NULL != header, "header should not be NULL" ) ; INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__CLSCATCLR_CALL ); _clsCataCallerMeta &meta = _meta[MAKE_REPLY_TYPE(header->opCode)] ; if ( (SINT32)meta.bufLen < header->messageLength ) { if ( NULL != meta.header ) { SDB_OSS_FREE( meta.header ) ; meta.bufLen = 0 ; } meta.header = ( MsgHeader *)SDB_OSS_MALLOC( header->messageLength ) ; if ( NULL == meta.header ) { PD_LOG ( PDERROR, "Failed to allocate memory for header" ) ; rc = SDB_OOM ; goto error ; } meta.bufLen = header->messageLength ; } ossMemcpy( meta.header, header, header->messageLength ) ; PD_LOG( PDEVENT, "send msg[%d] to catalog node.", meta.header->opCode ) ; pmdGetKRCB()->getClsCB()->sendToCatlog( meta.header ) ; meta.timeout = 0 ; done: PD_TRACE_EXITRC ( SDB__CLSCATCLR_CALL, rc ); return rc ; error: goto done ; }
static inline void freeRecord(bson* obj) { SDB_ASSERT(NULL != obj, "obj can't be NULL"); bson_destroy(obj); SDB_OSS_FREE(obj); }
INT32 rtnCoord2PhaseCommit::doPhase2( CHAR * pReceiveBuffer, SINT32 packSize, CHAR * * ppResultBuffer, pmdEDUCB * cb, MsgOpReply & replyHeader ) { INT32 rc = SDB_OK; pmdKRCB *pKrcb = pmdGetKRCB(); CoordCB *pCoordcb = pKrcb->getCoordCB(); netMultiRouteAgent *pRouteAgent = pCoordcb->getRouteAgent(); CHAR *pMsgReq = NULL; MsgHeader *pMsgHead = NULL; CoordGroupList groupLst; CoordGroupList sendGroupLst; rc = buildPhase2Msg( pReceiveBuffer, &pMsgReq ); PD_RC_CHECK( rc, PDERROR, "failed to build the message on phase1(rc=%d)", rc ); pMsgHead = (MsgHeader *)pMsgReq; pMsgHead->TID = cb->getTID(); rc = executeOnDataGroup( pMsgReq, pRouteAgent, cb ); PD_RC_CHECK( rc, PDERROR, "failed to execute on data-group on phase1(rc=%d)", rc ); done: if ( pMsgReq ) { SDB_OSS_FREE( pMsgReq ); pMsgReq = NULL; } return rc; error: goto done; }
_utilESBulkBuilder::~_utilESBulkBuilder() { if ( _buffer ) { SDB_OSS_FREE( _buffer ) ; } }
_utilESBulkActionBase::~_utilESBulkActionBase() { if ( _sourceData && _ownData ) { SDB_OSS_FREE( _sourceData ) ; } }
_pmdEDUCB::~_pmdEDUCB () { { ossScopedRWLock assist ( &_callInMutex, EXCLUSIVE ) ; } if ( _pErrorBuff ) { SDB_OSS_FREE ( _pErrorBuff ) ; _pErrorBuff = NULL ; } #if defined ( SDB_ENGINE ) DpsTransCBLockList::iterator iterLst = _transLockLst.begin(); while( iterLst != _transLockLst.end() ) { if ( iterLst->second ) { SDB_OSS_DEL iterLst->second ; } _transLockLst.erase( iterLst++ ); } if ( _pTransNodeMap ) { delete _pTransNodeMap; _pTransNodeMap = NULL; } #endif // SDB_ENGINE clear() ; }
INT32 rtnCoord2PhaseCommit::doPhase1( MsgHeader *pMsg, pmdEDUCB *cb, INT64 &contextID, rtnContextBuf *buf ) { INT32 rc = SDB_OK; CHAR *pMsgReq = NULL; rc = buildPhase1Msg( (CHAR*)pMsg, &pMsgReq ); PD_RC_CHECK( rc, PDERROR, "Failed to build the message on phase1(rc=%d)", rc ); // execute on data nodes rc = executeOnDataGroup( (MsgHeader*)pMsgReq, cb, contextID, buf ) ; PD_RC_CHECK( rc, PDERROR, "Failed to execute on data-group on phase1(rc=%d)", rc ) ; done: if ( pMsgReq ) { SDB_OSS_FREE( pMsgReq ); pMsgReq = NULL; } return rc; error: goto done; }
INT32 ossWC2ANSI ( LPCWSTR lpcszWCString, LPSTR *plppszString, DWORD *plpdwString ) { INT32 rc = SDB_OK ; INT32 strSize = 0 ; INT32 requiredSize = 0 ; requiredSize = WideCharToMultiByte ( CP_ACP, 0, lpcszWCString, -1, NULL, 0, NULL, NULL ) ; *plppszString = (LPSTR)SDB_OSS_MALLOC ( requiredSize ) ; if ( !plppszString ) { rc = SDB_OOM ; goto error ; } strSize = WideCharToMultiByte ( CP_ACP, 0, lpcszWCString, -1, *plppszString, requiredSize, NULL, NULL ) ; if ( 0 == strSize ) { SDB_OSS_FREE ( *plppszString ) ; rc = SDB_SYS ; *plppszString = NULL ; goto error ; } if ( plpdwString ) { *plpdwString = (DWORD)strSize ; } done : return rc ; error : goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__NETEVNHND__ALLOBUF, "_netEventHandler::_allocateBuf" ) INT32 _netEventHandler::_allocateBuf( UINT32 len ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__NETEVNHND__ALLOBUF ); if ( _bufLen < len ) { if ( NULL != _buf ) { SDB_OSS_FREE( _buf ) ; _bufLen = 0 ; } _buf = (CHAR *)SDB_OSS_MALLOC( len ) ; if ( NULL == _buf ) { PD_LOG( PDERROR, "mem allocate failed, len: %u", len ) ; rc = SDB_OOM ; goto error ; } _bufLen = len ; } done: PD_TRACE_EXITRC ( SDB__NETEVNHND__ALLOBUF, rc ); return rc ; error: goto done ; }
INT32 ossANSI2WC ( LPCSTR lpcszString, LPWSTR *plppszWCString, DWORD *plpdwWCString ) { INT32 rc = SDB_OK ; INT32 strSize = 0 ; INT32 requiredSize = 0 ; requiredSize = MultiByteToWideChar ( CP_ACP, 0, lpcszString, -1, NULL, 0 ) ; *plppszWCString = (LPWSTR)SDB_OSS_MALLOC ( requiredSize * sizeof(WCHAR) ) ; if ( !plppszWCString ) { rc = SDB_OOM ; goto error ; } strSize = MultiByteToWideChar ( CP_ACP, 0, lpcszString, -1, *plppszWCString, requiredSize ) ; if ( 0 == strSize ) { SDB_OSS_FREE ( *plppszWCString ) ; rc = SDB_SYS ; *plppszWCString = NULL ; goto error ; } if ( plpdwWCString ) *plpdwWCString = strSize ; done : return rc ; error : goto done ; }
void _rtnContextBuf::release() { if ( !_released ) { SDB_ASSERT( *_pBuffCounter > 0, "Counter must > 0" ) ; --(*_pBuffCounter) ; if ( 0 == *_pBuffCounter ) { if ( *RTN_GET_CONTEXT_FLAG( _pOrgBuff ) == 0 ) { SDB_OSS_FREE( RTN_BUFF_TO_REAL_PTR( _pOrgBuff ) ) ; } else { _pBuffLock->release_r() ; } } _pBuffCounter = NULL ; _pBuffLock = NULL ; _released = TRUE ; _pOrgBuff = NULL ; } _pBuff = NULL ; _buffSize = 0 ; _recordNum = 0 ; _curOffset = 0 ; _startFrom = 0 ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_RTNLOBDATAPOOL_ALLOCATE, "_rtnLobDataPool::allocate" ) INT32 _rtnLobDataPool::allocate( UINT32 len, CHAR **buf ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB_RTNLOBDATAPOOL_ALLOCATE ) ; SDB_ASSERT( NULL != buf, "can not be null" ) ; if ( len <= _bufSz ) { *buf = _buf ; goto done ; } else if ( NULL != _buf ) { SDB_OSS_FREE( _buf ) ; _bufSz = 0 ; } _buf = ( CHAR * )SDB_OSS_MALLOC( len ) ; if ( NULL == _buf ) { PD_LOG( PDERROR, "failed to allocate mem." ) ; rc = SDB_OOM ; goto error ; } _bufSz = len ; *buf = _buf ; done: PD_TRACE_EXITRC( SDB_RTNLOBDATAPOOL_ALLOCATE, rc ) ; return rc ; error: goto done ; }
INT32 _rtnQueryOptions::getOwned() { INT32 rc = SDB_OK ; if ( NULL != _fullNameBuf ) { SDB_OSS_FREE( _fullNameBuf ) ; _fullNameBuf = NULL ; } if ( NULL != _fullName ) { _fullNameBuf = ossStrdup( _fullName ) ; if ( NULL == _fullNameBuf ) { rc = SDB_OOM ; goto error ; } } _fullName = _fullNameBuf ; _query = _query.getOwned() ; _selector = _selector.getOwned() ; _orderBy = _orderBy.getOwned() ; _hint = _hint.getOwned() ; done: return rc ; error: goto done ; }
_netEventHandler::~_netEventHandler() { close() ; if ( NULL != _buf ) { SDB_OSS_FREE( _buf ) ; } }
_rtnLobWindow::~_rtnLobWindow() { if ( NULL != _pool ) { SDB_OSS_FREE( _pool ) ; _pool = NULL ; } }
restAdaptor::~restAdaptor() { if ( _pSettings ) { SDB_OSS_FREE( _pSettings ) ; _pSettings = NULL ; } }
INT32 rtnCoordTransRollback::execute( CHAR * pReceiveBuffer, SINT32 packSize, CHAR * * ppResultBuffer, pmdEDUCB * cb, MsgOpReply & replyHeader, BSONObj **ppErrorObj ) { INT32 rc = SDB_OK; CHAR *pMsgReq = NULL; MsgHeader *pMsgHead = NULL; INT32 bufferSize = 0; pmdKRCB *pKrcb = pmdGetKRCB(); CoordCB *pCoordcb = pKrcb->getCoordCB(); netMultiRouteAgent *pRouteAgent = pCoordcb->getRouteAgent(); MsgHeader *pHeader = (MsgHeader *)pReceiveBuffer; replyHeader.header.messageLength = sizeof( MsgOpReply ); replyHeader.header.opCode = MSG_BS_TRANS_ROLLBACK_RSP; replyHeader.header.routeID.value = 0; replyHeader.contextID = -1; replyHeader.flags = SDB_OK; replyHeader.numReturned = 0; replyHeader.startFrom = 0; if ( pHeader ) { replyHeader.header.requestID = pHeader->requestID; replyHeader.header.TID = pHeader->TID; } if ( !cb->isTransaction() ) { rc = SDB_DPS_TRANS_NO_TRANS; goto error; } cb->startRollback(); rc = msgBuildTransRollbackMsg( &pMsgReq, &bufferSize ); PD_RC_CHECK( rc, PDERROR, "failed to build the message(rc=%d)", rc ); pMsgHead = (MsgHeader *)pMsgReq; pMsgHead->TID = cb->getTID(); rc = executeOnDataGroup( pMsgReq, pRouteAgent, cb ); cb->delTransaction(); PD_RC_CHECK( rc, PDERROR, "failed to rollback(rc=%d)", rc ); done: if ( pMsgReq ) { SDB_OSS_FREE( pMsgReq ); } cb->stopRollback(); return rc; error: replyHeader.flags = rc; goto done; }
// PD_TRACE_DECLARE_FUNCTION( SDB__QGMPLDELETE__EXEC, "_qgmPlDelete::_execute" ) INT32 _qgmPlDelete::_execute( _pmdEDUCB *eduCB ) { PD_TRACE_ENTRY( SDB__QGMPLDELETE__EXEC ) ; INT32 rc = SDB_OK ; _SDB_KRCB *krcb = pmdGetKRCB() ; SDB_ROLE role = krcb->getDBRole() ; CHAR *msg = NULL ; if ( SDB_ROLE_COORD == role ) { INT32 bufSize = 0 ; MsgOpReply dummyReply ; rtnCoordDelete del ; rc = msgBuildDeleteMsg( &msg, &bufSize, _collection.toString().c_str(), 0, 0, _condition.isEmpty()? NULL : &_condition ) ; if ( SDB_OK != rc ) { goto error ; } rc = del.execute( msg, *((SINT32 *)msg), eduCB, dummyReply, NULL ) ; } else { SDB_DPSCB *dpsCB = krcb->getDPSCB() ; if ( dpsCB && eduCB->isFromLocal() && !dpsCB->isLogLocal() ) { dpsCB = NULL ; } SDB_DMSCB *dmsCB = krcb->getDMSCB() ; BSONObj empty ; rc = rtnDelete( _collection.toString().c_str(), _condition, empty, 0, eduCB, dmsCB, dpsCB ) ; } if ( SDB_OK != rc ) { goto error ; } done: if ( NULL != msg ) { SDB_OSS_FREE( msg ) ; msg = NULL ; } PD_TRACE_EXITRC( SDB__QGMPLDELETE__EXEC, rc ) ; return rc ; error: goto done ; }
~_monCollectionSpace() { vector<CHAR*>::iterator i ; for ( i = _collections.begin(); i != _collections.end(); ++i ) { SDB_OSS_FREE ( *i ) ; } _collections.clear() ; }
INT32 rtnCoordTransCommit::executeOnDataGroup( CHAR * pMsg, netMultiRouteAgent * pRouteAgent, pmdEDUCB * cb ) { INT32 rc = SDB_OK; REQUESTID_MAP requestIdMap; REPLY_QUE replyQue; MsgHeader *pMsgHead = (MsgHeader *)pMsg; DpsTransNodeMap *pNodeMap = cb->getTransNodeLst(); DpsTransNodeMap::iterator iterMap = pNodeMap->begin(); while( iterMap != pNodeMap->end() ) { rc = rtnCoordSendRequestToNode( (void *)pMsg, iterMap->second, pRouteAgent, cb, requestIdMap ); if ( rc ) { rtnCoordClearRequest( cb, requestIdMap ); } PD_RC_CHECK( rc, PDERROR, "failed to send the request to the node" "(groupID=%u, nodeID=%u, rc=%d). ", iterMap->second.columns.groupID, iterMap->second.columns.nodeID, rc ); ++iterMap; } rc = rtnCoordGetReply( cb, requestIdMap, replyQue, MAKE_REPLY_TYPE( pMsgHead->opCode ) ) ; PD_RC_CHECK( rc, PDERROR, "failed to get the reply(rc=%d)", rc ); while ( !replyQue.empty() ) { MsgOpReply *pReply = NULL; pReply = (MsgOpReply *)(replyQue.front()); replyQue.pop(); INT32 rcTmp = pReply->flags; if ( rcTmp != SDB_OK ) { rc = rc ? rc : rcTmp; PD_LOG( PDERROR, "failed to execute on data node(rc=%d, groupID=%u, nodeID=%u)", rcTmp, pReply->header.routeID.columns.groupID, pReply->header.routeID.columns.nodeID ); } SDB_OSS_FREE( pReply ); } if ( rc ) { goto error; } done: return rc; error: goto done; }
_rtnQueryOptions::~_rtnQueryOptions() { if ( NULL != _fullNameBuf ) { SDB_OSS_FREE( _fullNameBuf ) ; } _fullName = NULL ; _fullNameBuf = NULL ; }
INT32 cCMService::fini() { if ( _pArgs ) { SDB_OSS_FREE( _pArgs ) ; _pArgs = NULL ; _argLen = 0 ; } return SDB_OK ; }
~_clsCataCallerMeta() { if ( NULL != header ) { SDB_OSS_FREE( header ) ; header = NULL ; } bufLen = 0 ; timeout = -1 ; }
OSS_INLINE void _dmsStorageData::_collectionNameMapCleanup () { COLNAME_MAP_CIT it = _collectionNameMap.begin() ; for ( ; it != _collectionNameMap.end() ; ++it ) { SDB_OSS_FREE( const_cast<CHAR *>(it->first) ) ; } _collectionNameMap.clear() ; }
OSS_INLINE void _dmsStorageData::_collectionNameRemove( const CHAR * pName ) { COLNAME_MAP_IT it = _collectionNameMap.find( pName ) ; if ( _collectionNameMap.end() != it ) { const CHAR *tp = (*it).first ; _collectionNameMap.erase( it ) ; SDB_OSS_FREE( const_cast<CHAR *>(tp) ) ; } }
_rtnLobDataPool::~_rtnLobDataPool() { clear() ; if ( NULL != _buf ) { SDB_OSS_FREE( _buf ) ; _buf = NULL ; _bufSz = 0 ; } }
INT32 rtnCoordTransCommit::buildPhase2Msg( CHAR * pReceiveBuffer, CHAR **pMsg ) { SDB_ASSERT( pMsg, "pMsg can't be NULL" ) ; INT32 bufferSize = 0; if ( *pMsg != NULL ) { SDB_OSS_FREE( pMsg ); *pMsg = NULL; } return msgBuildTransCommitMsg( pMsg, &bufferSize ); }
_qgmPtrTable::~_qgmPtrTable() { _table.clear() ; STR_TABLE::iterator it = _stringTable.begin() ; while ( it != _stringTable.end() ) { SDB_OSS_FREE( *it ) ; ++it ; } _stringTable.clear() ; }