Commit 2ff1df49 authored by David COME's avatar David COME
Browse files

Fixed goingToEnd and used it to terminate the loop

ReportEndofSession(WithErrors)::goingToEnd returns now true as it should and RecallReportPacker.M-terminate has been removed by goingToEnd+break if true
parent 0a55e07a
......@@ -37,7 +37,7 @@ using castor::log::Param;
RecallReportPacker::RecallReportPacker(client::ClientInterface & tg,unsigned int reportFilePeriod,log::LogContext lc):
ReportPackerInterface<detail::Recall>(tg,lc),
m_workerThread(*this),m_reportFilePeriod(reportFilePeriod),m_errorHappened(false),m_continue(true){
m_workerThread(*this),m_reportFilePeriod(reportFilePeriod),m_errorHappened(false){
}
RecallReportPacker::~RecallReportPacker(){
......@@ -89,6 +89,9 @@ void RecallReportPacker::flush(){
client::ClientInterface::RequestReport chrono;
m_client.reportRecallResults(*m_listReports,chrono);
//delete the old pointer and remplace it with the new one provided
//that way, all the reports that have been send are deleted (by m_listReports's destructor)
m_listReports.reset(new FileReportList);
}
}
......@@ -105,7 +108,6 @@ void RecallReportPacker::ReportEndofSession::execute(RecallReportPacker& _this){
_this.m_client.reportEndOfSessionWithError(msg,SEINTERNAL,chrono);
//throw castor::exception::Exception(msg);
}
_this.m_continue=false;
}
void RecallReportPacker::ReportEndofSessionWithErrors::execute(RecallReportPacker& _this){
......@@ -121,7 +123,6 @@ void RecallReportPacker::ReportEndofSessionWithErrors::execute(RecallReportPacke
_this.m_client.reportEndOfSessionWithError(msg,SEINTERNAL,chrono);
//throw castor::exception::Exception(msg);
}
_this.m_continue=false;
}
void RecallReportPacker::ReportError::execute(RecallReportPacker& _this){
......@@ -145,17 +146,22 @@ m_parent(parent) {
}
void RecallReportPacker::WorkerThread::run(){
while(m_parent.m_continue) {
while(1) {
std::auto_ptr<Report> rep (m_parent.m_fifo.pop());
unsigned int totalSize = m_parent.m_listReports->failedRecalls().size() +
m_parent.m_listReports->successfulRecalls().size();
if(totalSize >= m_parent.m_reportFilePeriod || true==rep->goingToEnd())
if(totalSize >= m_parent.m_reportFilePeriod || rep->goingToEnd())
{
m_parent.flush();
}
rep->execute(m_parent);
if(rep->goingToEnd()) {
break;
}
}
}
}}}}
......@@ -99,7 +99,7 @@ private:
};
class ReportEndofSession : public Report {
public:
ReportEndofSession():Report(false){}
ReportEndofSession():Report(true){}
virtual void execute(RecallReportPacker& _this);
};
class ReportEndofSessionWithErrors : public Report {
......@@ -107,7 +107,7 @@ private:
int m_error_code;
public:
ReportEndofSessionWithErrors(std::string msg,int error_code):
Report(false),m_message(msg),m_error_code(error_code){}
Report(true),m_message(msg),m_error_code(error_code){}
virtual void execute(RecallReportPacker& _this);
};
......@@ -130,7 +130,6 @@ private:
unsigned int m_reportFilePeriod;
bool m_errorHappened;
bool m_continue;
};
}}}}
......
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