Beispiel #1
0
   void _pmdEDUCB::saveBuffs( _pmdEDUCB::CATCH_MAP &catchMap )
   {
      if ( _pCompressBuff )
      {
         releaseBuff( _pCompressBuff ) ;
         _pCompressBuff = NULL ;
      }
      _compressBuffLen = 0 ;
      if ( _pUncompressBuff )
      {
         releaseBuff( _pUncompressBuff ) ;
         _pUncompressBuff = NULL ;
      }
      _uncompressBuffLen = 0 ;

      CHAR *pBuff = NULL ;
      ALLOC_MAP_IT itAlloc = _allocMap.begin() ;
      while ( itAlloc != _allocMap.end() )
      {
         pBuff = itAlloc->first ;
         ++itAlloc ;
         releaseBuff( pBuff ) ;
      }
      _allocMap.clear() ;

      CATCH_MAP_IT it = _catchMap.begin() ;
      while ( it != _catchMap.end() )
      {
         _totalCatchSize -= it->first ;
         _totalMemSize -= it->first ;
         catchMap.insert( std::make_pair( it->first, it->second ) ) ;
         ++it ;
      }
      _catchMap.clear() ;
   }
Beispiel #2
0
   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" ) ;
   }
Beispiel #3
0
void _pmdSession::clear ()
{
    if ( _pBuff )
    {
        releaseBuff( _pBuff, _buffLen ) ;
        _pBuff = NULL ;
    }
    _buffLen = 0 ;
}
Beispiel #4
0
   INT32 _pmdEDUCB::reallocBuff( INT32 len, CHAR **ppBuff, INT32 &buffLen )
   {
      INT32 rc = SDB_OK ;
      CHAR *pOld = *ppBuff ;
      INT32 oldLen = buffLen ;

      ALLOC_MAP_IT itAlloc = _allocMap.find( *ppBuff ) ;
      if ( itAlloc != _allocMap.end() )
      {
         buffLen = itAlloc->second ;
         oldLen = buffLen ;
      }
      else if ( *ppBuff != NULL || buffLen != 0 )
      {
         PD_LOG( PDERROR, "EDU[%s] realloc input buffer error",
                 toString().c_str() ) ;
         rc = SDB_SYS ;
         goto error ;
      }

      if ( buffLen >= len )
      {
         goto done ;
      }
      len = ossRoundUpToMultipleX( len, EDU_MEM_ALIGMENT_SIZE ) ;
      *ppBuff = ( CHAR* )SDB_OSS_REALLOC( *ppBuff, len ) ;
      if ( !*ppBuff )
      {
         PD_LOG( PDERROR, "Failed to realloc memory, size: %d", len ) ;
         goto error ;
      }

      buffLen = len ;

      _totalMemSize += ( len - oldLen ) ;

      _allocMap[ *ppBuff ] = buffLen ;

   done:
      return rc ;
   error:
      if ( pOld )
      {
         releaseBuff( pOld ) ;
         *ppBuff = NULL ;
         buffLen = 0 ;
      }
      goto done ;
   }
Beispiel #5
0
   CHAR* _pmdEDUCB::getUncompressBuff( INT32 len )
   {
      if ( _uncompressBuffLen < len )
      {
         if ( _pUncompressBuff )
         {
            releaseBuff( _pUncompressBuff ) ;
            _pUncompressBuff = NULL ;
         }
         _uncompressBuffLen = 0 ;

         allocBuff( len, &_pUncompressBuff, _uncompressBuffLen ) ;
      }

      return _pUncompressBuff ;
   }
Beispiel #6
0
CHAR* _pmdSession::getBuff( INT32 len )
{
    if ( _buffLen < len )
    {
        if ( _pBuff )
        {
            releaseBuff( _pBuff, _buffLen ) ;
            _pBuff = NULL ;
        }
        _buffLen = 0 ;

        allocBuff( len, &_pBuff, _buffLen ) ;
    }

    return _pBuff ;
}
 //-----------------------------------------------------------------------------
 NetIocpBufBlock::~NetIocpBufBlock()
 {
     releaseBuff();
 }