Commit d0307c48 authored by Eric Cano's avatar Eric Cano
Browse files

Fixed memory leak in case of exception.

parent b77af9a8
...@@ -85,7 +85,7 @@ void RecallTaskInjector::startThreads() { ...@@ -85,7 +85,7 @@ void RecallTaskInjector::startThreads() {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//injectBulkRecalls //injectBulkRecalls
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *>& jobs) { void RecallTaskInjector::injectBulkRecalls(std::vector<std::unique_ptr<cta::RetrieveJob>>& jobs) {
for (auto it = jobs.begin(); it != jobs.end(); ++it) { for (auto it = jobs.begin(); it != jobs.end(); ++it) {
(*it)->positioningMethod=cta::PositioningMethod::ByBlock; (*it)->positioningMethod=cta::PositioningMethod::ByBlock;
...@@ -101,8 +101,9 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *> ...@@ -101,8 +101,9 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *>
m_lc.log(LOG_INFO, "Recall task created"); m_lc.log(LOG_INFO, "Recall task created");
DiskWriteTask * dwt = new DiskWriteTask(*it, m_memManager); cta::RetrieveJob *job = it->get();
TapeReadTask * trt = new TapeReadTask(*it, *dwt, m_memManager); DiskWriteTask * dwt = new DiskWriteTask(it->release(), m_memManager);
TapeReadTask * trt = new TapeReadTask(job, *dwt, m_memManager);
m_diskWriter.push(dwt); m_diskWriter.push(dwt);
m_tapeReader.push(trt); m_tapeReader.push(trt);
...@@ -116,7 +117,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *> ...@@ -116,7 +117,7 @@ void RecallTaskInjector::injectBulkRecalls(const std::vector<cta::RetrieveJob *>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool RecallTaskInjector::synchronousInjection() bool RecallTaskInjector::synchronousInjection()
{ {
std::vector<cta::RetrieveJob *> jobs; std::vector<std::unique_ptr<cta::RetrieveJob>> jobs;
try { try {
uint64_t files=0; uint64_t files=0;
...@@ -126,7 +127,7 @@ bool RecallTaskInjector::synchronousInjection() ...@@ -126,7 +127,7 @@ bool RecallTaskInjector::synchronousInjection()
if(!job.get()) break; if(!job.get()) break;
files++; files++;
bytes+=job->archiveFile.size; bytes+=job->archiveFile.size;
jobs.push_back(job.release()); jobs.emplace_back(job.release());
} }
} catch (castor::exception::Exception & ex) { } catch (castor::exception::Exception & ex) {
castor::log::ScopedParamContainer scoped(m_lc); castor::log::ScopedParamContainer scoped(m_lc);
...@@ -185,7 +186,7 @@ void RecallTaskInjector::WorkerThread::run() ...@@ -185,7 +186,7 @@ void RecallTaskInjector::WorkerThread::run()
break; break;
} }
m_parent.m_lc.log(LOG_DEBUG,"RecallJobInjector:run: about to call client interface"); m_parent.m_lc.log(LOG_DEBUG,"RecallJobInjector:run: about to call client interface");
std::vector<cta::RetrieveJob *> jobs; std::vector<std::unique_ptr<cta::RetrieveJob>> jobs;
uint64_t files=0; uint64_t files=0;
uint64_t bytes=0; uint64_t bytes=0;
...@@ -194,7 +195,7 @@ void RecallTaskInjector::WorkerThread::run() ...@@ -194,7 +195,7 @@ void RecallTaskInjector::WorkerThread::run()
if(!job.get()) break; if(!job.get()) break;
files++; files++;
bytes+=job->archiveFile.size; bytes+=job->archiveFile.size;
jobs.push_back(job.release()); jobs.emplace_back(job.release());
} }
LogContext::ScopedParam sp01(m_parent.m_lc, Param("transactionId", m_parent.m_retrieveMount.getMountTransactionId())); LogContext::ScopedParam sp01(m_parent.m_lc, Param("transactionId", m_parent.m_retrieveMount.getMountTransactionId()));
......
...@@ -126,7 +126,7 @@ private: ...@@ -126,7 +126,7 @@ private:
* Create all the tape-read and write-disk tasks for set of files to retrieve * Create all the tape-read and write-disk tasks for set of files to retrieve
* @param jobs * @param jobs
*/ */
void injectBulkRecalls(const std::vector<cta::RetrieveJob *>& jobs); void injectBulkRecalls(std::vector<std::unique_ptr<cta::RetrieveJob>>& jobs);
/** /**
* A request of files to recall. We request EITHER * A request of files to recall. We request EITHER
......
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