Commit 4d3317d2 authored by David COME's avatar David COME
Browse files

Properly clone FileToRecallStruct into RecallTaskInjector

and thus changed the type to an auto_ptr into DiskWriteTask
parent 3077b50d
......@@ -30,7 +30,7 @@
#include "castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include "castor/tape/tapeserver/file/File.hpp"
#include "castor/tape/tapegateway/FileToRecallStruct.hpp"
#include <memory>
namespace {
uint32_t blockID(const castor::tape::tapegateway::FileToRecallStruct& ftr)
......@@ -72,8 +72,8 @@ public:
* @param blockCount: number of memory blocks that will be used
* @param mm: memory manager of the session
*/
DiskWriteTask(const tape::tapegateway::FileToRecallStruct& file,MemoryManager& mm):
m_blockCount(blockID(file)),m_fifo(m_blockCount),m_recallingFile(file),m_memManager(mm){
DiskWriteTask(tape::tapegateway::FileToRecallStruct* file,MemoryManager& mm):
m_blockCount(blockID(*file)),m_fifo(m_blockCount),m_recallingFile(file),m_memManager(mm){
mm.addClient(&m_fifo);
}
......@@ -95,17 +95,17 @@ public:
using log::LogContext;
using log::Param;
try{
tape::diskFile::WriteFile writer(m_recallingFile.path());
tape::diskFile::WriteFile writer(m_recallingFile->path());
int blockId = 0;
while(!m_fifo.finished()) {
MemBlock *mb = m_fifo.popDataBlock();
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){
LogContext::ScopedParam sp[]={
LogContext::ScopedParam(lc, Param("expectedFILEID",m_recallingFile.fileid())),
LogContext::ScopedParam(lc, Param("expectedFILEID",m_recallingFile->fileid())),
LogContext::ScopedParam(lc, Param("receivedFILEID", mb->m_fileid)),
LogContext::ScopedParam(lc, Param("expectedFBLOCKId", blockId)),
LogContext::ScopedParam(lc, Param("receivedFBLOCKId", mb->m_fileBlock)),
......@@ -118,11 +118,11 @@ public:
}
writer.close();
//a log is done in m_reporter while processing reportCompletedJob
reporter.reportCompletedJob(m_recallingFile);
reporter.reportCompletedJob(*m_recallingFile);
}
catch(const castor::exception::Exception& e){
//a log is done in m_reporter while processing reportFailedJob
reporter.reportFailedJob(m_recallingFile,e.getMessageValue(),e.code());
reporter.reportFailedJob(*m_recallingFile,e.getMessageValue(),e.code());
}
}
......@@ -169,7 +169,7 @@ private:
/**
* All we need to know about the file we are currently recalling
*/
tape::tapegateway::FileToRecallStruct m_recallingFile;
std::auto_ptr<tape::tapegateway::FileToRecallStruct> m_recallingFile;
/**
* Reference to the Memory Manager in use
......
......@@ -9,6 +9,12 @@
using castor::log::LogContext;
using castor::log::Param;
namespace{
castor::tape::tapegateway::FileToRecallStruct* removeOwningList(castor::tape::tapegateway::FileToRecallStruct* ptr){
ptr->setFilesToRecallList(NULL);
return ptr;
}
}
namespace castor{
namespace tape{
......@@ -53,7 +59,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<castor::tape::tapeg
m_lc.log(LOG_INFO, "Logged file to recall");
DiskWriteTask * dwt = new DiskWriteTask(**it ,m_memManager);
DiskWriteTask * dwt = new DiskWriteTask(removeOwningList(dynamic_cast<tape::tapegateway::FileToRecallStruct*>((*it)->clone())) ,m_memManager);
TapeReadFileTask * trt = new TapeReadFileTask(*dwt, (*it)->fseq(), blockID(**it));
m_diskWriter.push(dwt);
......
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