// PD_TRACE_DECLARE_FUNCTION ( SDB_PMDLOGGWENTPNT, "pmdLoggWEntryPoint" ) INT32 pmdLoggWEntryPoint ( pmdEDUCB *cb, void *pData ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_PMDLOGGWENTPNT ); pmdEDUMgr * eduMgr = cb->getEDUMgr() ; SDB_DPSCB *dpsCb = ( SDB_DPSCB* )pData ; rc = eduMgr->activateEDU ( cb ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to activate EDU" ) ; goto error ; } while ( !cb->isDisconnected() ) { rc = dpsCb->run( cb ); if ( rc ) { PD_LOG ( PDSEVERE, "Failed to run dpsCB, rc = %d", rc ) ; ossPanic () ; } } rc = dpsCb->tearDown(); if ( rc ) { PD_LOG ( PDSEVERE, "Failed to run tearDown(), rc = %d", rc ) ; ossPanic() ; } done : PD_TRACE_EXITRC ( SDB_PMDLOGGWENTPNT, rc ); return rc; error : switch ( rc ) { case SDB_SYS : PD_LOG ( PDSEVERE, "System error occured" ) ; break ; default : PD_LOG ( PDSEVERE, "Internal error, rc = %d", rc ) ; } goto done ; }
// write data into log file // PD_TRACE_DECLARE_FUNCTION ( SDB__DPSLOGFILE_WRITE, "_dpsLogFile::write" ) INT32 _dpsLogFile::write( const CHAR *content, UINT32 len ) { INT32 rc = SDB_OK; PD_TRACE_ENTRY ( SDB__DPSLOGFILE_WRITE ); _dirty = TRUE ; if ( len <= _idleSize && _idleSize <= _fileSize ) { SINT64 writtenLen = 0 ; UINT32 written = 0 ; while ( written < len ) { // write data into the file // _fileSize - _idleSize is the offset for the current position rc = ossSeekAndWrite( _file, DPS_LOG_HEAD_LEN + _fileSize - _idleSize + written, &content[written], len - written, &writtenLen ) ; if ( SDB_OK == rc ) { written += (UINT32)writtenLen ; } else { PD_LOG ( PDERROR, "Failed to write page data into file[%s], " "written: %u, len: %u, rc = %d", toString().c_str(), written, len, rc ) ; goto error; } } _idleSize -= len ; } else if ( len > _idleSize ) { PD_LOG( PDERROR, "Write page data failed, len[%u] grater than " "idle size in log file[%s]", len, toString().c_str() ) ; rc = SDB_SYS ; goto error ; } else { PD_LOG( PDERROR, "Wrong idle in log file[%s]", toString().c_str() ) ; rc = SDB_SYS ; goto error ; } _writeEvent.signalAll() ; done: PD_TRACE_EXITRC ( SDB__DPSLOGFILE_WRITE, rc ); return rc; error: ossPanic() ; goto done; }