Commit 3cf199bf authored by David COME's avatar David COME
Browse files

Added into DiskWriteTask a mecanism to release all memory blocks in case of error

parent 45009058
...@@ -113,16 +113,24 @@ public: ...@@ -113,16 +113,24 @@ public:
return true; return true;
} }
catch(const castor::exception::Exception& e){ catch(const castor::exception::Exception& e){
/*
*We might end up there with some blocks into m_fifo
* We need to empty it
*/
releaseAllBlock();
reporter.reportFailedJob(*m_recallingFile,e.getMessageValue(),e.code()); reporter.reportFailedJob(*m_recallingFile,e.getMessageValue(),e.code());
return false; return false;
} }
} }
/** /**
* Allows client code to return a reusable memory block * Allows client code to return a reusable memory block. Should not been called
* @return the pointer to the memory block that can be reused * @return the pointer to the memory block that can be reused
*/ */
virtual MemBlock *getFreeBlock() { return m_fifo.pop(); } virtual MemBlock *getFreeBlock() {
throw castor::tape::Exception("DiskWriteTask::getFreeBlock should mot be called");
}
/** /**
* Function used to enqueue a new memory block holding data to be written to disk * Function used to enqueue a new memory block holding data to be written to disk
...@@ -142,6 +150,18 @@ public: ...@@ -142,6 +150,18 @@ public:
private: private:
void releaseAllBlock(){
try
{
while(1){
MemBlock* mb=m_fifo.tryPop();
if(mb) {
AutoReleaseBlock(mb,m_memManager);
}
}
}
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