Commit 352db341 authored by Eric Cano's avatar Eric Cano
Browse files

Added fifo checker on recall report packer exit to cleanup and report on leaked messages.

Re-enabled the unit test, which does not leak memory (but logs errors instead).
parent 329d7331
......@@ -304,7 +304,7 @@ protected:
}; // class DataTransferSessionTest
TEST_P(DataTransferSessionTest, DISABLED_DataTransferSessionGooddayRecall) {
TEST_P(DataTransferSessionTest, DataTransferSessionGooddayRecall) {
// 0) Prepare the logger for everyone
castor::log::StringLogger logger("tapeServerUnitTest");
......
......@@ -218,11 +218,20 @@ void RecallReportPacker::WorkerThread::run(){
m_parent.m_lc.log(LOG_DEBUG, "Starting RecallReportPacker thread");
bool endFound = false;
try{
while(1) {
while(1) {
std::string debugType;
std::unique_ptr<Report> rep(m_parent.m_fifo.pop());
{
log::ScopedParamContainer spc(m_parent.m_lc);
spc.add("ReportType", debugType=typeid(*rep).name());
if (rep->goingToEnd())
spc.add("goingToEnd", "true");
m_parent.m_lc.log(LOG_DEBUG, "Popping report");
}
// Record whether we found end before calling the potentially exception
// throwing execute().)
if (rep->goingToEnd()) endFound=true;
if (rep->goingToEnd())
endFound=true;
rep->execute(m_parent);
if (endFound) break;
}
......@@ -275,6 +284,16 @@ void RecallReportPacker::WorkerThread::run(){
break;
}
}
// Cross check that the queue is indeed empty.
while (m_parent.m_fifo.size()) {
// There is at least one extra report we missed.
log::ScopedParamContainer spc(m_parent.m_lc);
std::unique_ptr<Report> missedReport(m_parent.m_fifo.pop());
spc.add("ReportType", typeid(*missedReport).name());
if (missedReport->goingToEnd())
spc.add("goingToEnd", "true");
m_parent.m_lc.log(LOG_ERR, "Popping missed report (memory leak)");
}
m_parent.m_lc.log(LOG_DEBUG, "Finishing RecallReportPacker thread");
}
......
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