Commit e0039b10 authored by David COME's avatar David COME
Browse files

Changed DiskWriteTask main loop and method to release all the block

parent 2a26aaa3
...@@ -86,29 +86,29 @@ public: ...@@ -86,29 +86,29 @@ public:
tape::diskFile::WriteFile ourFile(m_recallingFile->path()); tape::diskFile::WriteFile ourFile(m_recallingFile->path());
int blockId = 0; int blockId = 0;
MemBlock *mb = m_fifo.pop(); while(1) {
while(NULL!=mb){ if(MemBlock* const mb = m_fifo.pop()) {
AutoReleaseBlock releaser(mb,m_memManager);
AutoReleaseBlock releaser(mb,m_memManager);
if(m_recallingFile->fileid() != static_cast<unsigned int>(mb->m_fileid)
if(m_recallingFile->fileid() != static_cast<unsigned int>(mb->m_fileid) || blockId != mb->m_fileBlock || mb->m_failled ){
|| blockId != mb->m_fileBlock || mb->m_failled ){ LogContext::ScopedParam sp[]={
LogContext::ScopedParam sp[]={ LogContext::ScopedParam(lc, Param("expected_NSFILEID",m_recallingFile->fileid())),
LogContext::ScopedParam(lc, Param("expected_NSFILEID",m_recallingFile->fileid())), LogContext::ScopedParam(lc, Param("received_NSFILEID", mb->m_fileid)),
LogContext::ScopedParam(lc, Param("received_NSFILEID", mb->m_fileid)), LogContext::ScopedParam(lc, Param("expected_NSFBLOCKId", blockId)),
LogContext::ScopedParam(lc, Param("expected_NSFBLOCKId", blockId)), LogContext::ScopedParam(lc, Param("received_NSFBLOCKId", mb->m_fileBlock)),
LogContext::ScopedParam(lc, Param("received_NSFBLOCKId", mb->m_fileBlock)), LogContext::ScopedParam(lc, Param("failed_Status", mb->m_failled))
LogContext::ScopedParam(lc, Param("failed_Status", mb->m_failled)) };
}; tape::utils::suppresUnusedVariable(sp);
tape::utils::suppresUnusedVariable(sp); lc.log(LOG_ERR,"received a bad block for writing");
lc.log(LOG_ERR,"received a bad block for writing"); throw castor::tape::Exception("received a bad block for writing");
throw castor::tape::Exception("received a bad block for writing"); }
mb->m_payload.write(ourFile);
blockId++;
} }
mb->m_payload.write(ourFile); else
mb = m_fifo.pop(); break;
blockId++; } //end of while(1)
}
ourFile.close();
reporter.reportCompletedJob(*m_recallingFile); reporter.reportCompletedJob(*m_recallingFile);
return true; return true;
} }
...@@ -151,16 +151,13 @@ public: ...@@ -151,16 +151,13 @@ public:
private: private:
void releaseAllBlock(){ void releaseAllBlock(){
try while(1){
{ MemBlock* mb=m_fifo.pop();
while(1){ if(mb)
MemBlock* mb=m_fifo.tryPop(); AutoReleaseBlock release(mb,m_memManager);
if(mb) { else
AutoReleaseBlock(mb,m_memManager); break;
} }
}
}
catch(const castor::tape::threading::noMore&){}
} }
/** /**
* The fifo containing the memory blocks holding data to be written to disk * The fifo containing the memory blocks holding data to be written to disk
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment