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

Added the passing of the log context as a parameter to DiskReadThreadPool::popAndRequestMore.

Otherwise, there was a race condition between the control thread and the worker threads.
Now, the log context of the worker thread is passed and used by popAndRequestMore.
parent 704324e5
......@@ -71,27 +71,28 @@ namespace daemon {
m_tasks.push(NULL);
}
}
DiskReadTaskInterface* DiskReadThreadPool::popAndRequestMore(){
DiskReadTaskInterface* DiskReadThreadPool::popAndRequestMore(castor::log::LogContext &lc){
castor::tape::threading::BlockingQueue<DiskReadTaskInterface*>::valueRemainingPair
vrp = m_tasks.popGetSize();
log::LogContext::ScopedParam sp(m_lc, log::Param("m_maxFilesReq", m_maxFilesReq));
log::LogContext::ScopedParam sp0(m_lc, log::Param("m_maxBytesReq", m_maxBytesReq));
log::LogContext::ScopedParam sp(lc, log::Param("m_maxFilesReq", m_maxFilesReq));
log::LogContext::ScopedParam sp0(lc, log::Param("m_maxBytesReq", m_maxBytesReq));
if(0==vrp.remaining){
m_injector->requestInjection(true);
m_lc.log(LOG_DEBUG, "Requested injection from MigrationTaskInjector (with last call)");
lc.log(LOG_DEBUG, "Requested injection from MigrationTaskInjector (with last call)");
}else if(vrp.remaining + 1 == m_maxFilesReq/2){
m_injector->requestInjection(false);
m_lc.log(LOG_DEBUG, "Requested injection from MigrationTaskInjector (without last call)");
lc.log(LOG_DEBUG, "Requested injection from MigrationTaskInjector (without last call)");
}
return vrp.value;
}
void DiskReadThreadPool::DiskReadWorkerThread::run() {
m_lc.pushOrReplace(log::Param("thread", "DiskRead"));
m_lc.pushOrReplace(log::Param("threadID",m_threadID));
m_lc.log(LOG_DEBUG, "DiskReadWorkerThread Running");
std::auto_ptr<DiskReadTaskInterface> task;
while(1) {
task.reset( m_parent.popAndRequestMore());
task.reset( m_parent.popAndRequestMore(m_lc));
if (NULL!=task.get()) {
task->execute(m_lc);
}
......
......@@ -66,7 +66,7 @@ private:
* it will ask the TaskInjector to get more job
* @return the next task to execute
*/
DiskReadTaskInterface* popAndRequestMore();
DiskReadTaskInterface* popAndRequestMore(castor::log::LogContext & lc);
class DiskReadWorkerThread: private castor::tape::threading::Thread {
public:
......
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