Commit 5c78c81e authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Corrected helgrind errors by adding mutexes for multithread access to...

Corrected helgrind errors by adding mutexes for multithread access to RecallReportPacker attributes.
parent 9694a7e4
......@@ -237,7 +237,7 @@ namespace cta {
/**
* A pointer to the file catalogue.
*/
cta::catalogue::Catalogue &m_catalogue;
cta::catalogue::Catalogue &m_catalogue;
}; // class RetrieveMount
......
......@@ -168,7 +168,8 @@ bool RecallReportPacker::ReportEndofSession::goingToEnd() {
void RecallReportPacker::ReportDriveStatus::execute(RecallReportPacker& parent){
parent.m_retrieveMount->setDriveStatus(m_status);
if(m_status==cta::common::dataStructures::DriveStatus::Unmounting) {
parent.m_retrieveMount->tapeComplete();
parent.setTapeDone();
parent.setTapeComplete();
}
}
......@@ -322,11 +323,11 @@ void RecallReportPacker::WorkerThread::run(){
// Make sure the last batch of reports got cleaned up.
try {
m_parent.fullCheckAndFinishAsyncExecute();
if(m_parent.m_diskThreadComplete){
if(m_parent.isDiskDone()){
//The m_parent.m_diskThreadComplete is set to true when a ReportEndOfSession or a ReportAndOfSessionWithError
//has been put. It is only after the fullCheckandFinishAsyncExecute is finished that we can say to the mount that the disk thread is complete.
m_parent.m_lc.log(cta::log::DEBUG, "In RecallReportPacker::WorkerThread::run(): all disk threads are finished, telling the mount that Disk threads are complete");
m_parent.m_retrieveMount->diskComplete();
m_parent.setDiskComplete();
}
} catch(const cta::exception::Exception& e){
cta::log::ScopedParamContainer params(m_parent.m_lc);
......@@ -395,14 +396,30 @@ void RecallReportPacker::fullCheckAndFinishAsyncExecute() {
//reportTapeDone()
//------------------------------------------------------------------------------
void RecallReportPacker::setTapeDone() {
cta::threading::MutexLocker mutexLocker(m_mutexTapeDone);
m_tapeThreadComplete = true;
}
void RecallReportPacker::setTapeComplete(){
cta::threading::MutexLocker mutexLocker(m_mutexSetTapeComplete);
m_retrieveMount->tapeComplete();
}
void RecallReportPacker::setDiskComplete(){
cta::threading::MutexLocker mutexLocker(m_mutexSetDiskComplete);
m_retrieveMount->diskComplete();
}
bool RecallReportPacker::isDiskDone(){
cta::threading::MutexLocker mutexLocker(m_mutexDiskDone);
return m_diskThreadComplete;
}
//------------------------------------------------------------------------------
//reportDiskDone()
//------------------------------------------------------------------------------
void RecallReportPacker::setDiskDone() {
cta::threading::MutexLocker mutexLocker(m_mutexDiskDone);
m_diskThreadComplete = true;
}
......
......@@ -98,6 +98,12 @@ public:
*/
virtual void setTapeDone();
void setTapeComplete();
void setDiskComplete();
bool isDiskDone();
/**
* Query the status of disk and tape threads (are they both done?).
* @return true if both tape and disk threads are done.
......@@ -227,6 +233,14 @@ private:
*/
bool m_diskThreadComplete;
cta::threading::Mutex m_mutexSetTapeComplete;
cta::threading::Mutex m_mutexSetDiskComplete;
cta::threading::Mutex m_mutexDiskDone;
cta::threading::Mutex m_mutexTapeDone;
/*
* Proceed finish procedure for async execute for all reports.
*
......
......@@ -356,6 +356,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
params.add("status", "success");
m_stats.totalTime = totalTimer.secs();
m_rrp.setTapeDone();
m_rrp.setTapeComplete();
logWithStat(cta::log::INFO, "Tape thread complete",
params);
// Report one last time the stats, after unloading/unmounting.
......
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