From cae3ef87cd5fdda82a3d2b5f7d52216a9c7c9697 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 31 Jul 2012 18:59:13 +0200 Subject: [PATCH] Changed: #1440 Handle more exit cases --HG-- branch : build_pipeline_v3 --- .../tools/pipeline/service/database_status.cpp | 2 +- .../pipeline/service/module_pipeline_master.cpp | 15 +++++++++++++-- .../pipeline/service/module_pipeline_slave.cpp | 6 ++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/code/nel/tools/pipeline/service/database_status.cpp b/code/nel/tools/pipeline/service/database_status.cpp index 046504f12..198aa6445 100644 --- a/code/nel/tools/pipeline/service/database_status.cpp +++ b/code/nel/tools/pipeline/service/database_status.cpp @@ -414,7 +414,7 @@ void updatePathStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, cons void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, const std::string &dir, bool recurse) { - if (!g_IsMaster) + if (!g_IsExiting && !g_IsMaster) { nlerror("Not master, not allowed."); } diff --git a/code/nel/tools/pipeline/service/module_pipeline_master.cpp b/code/nel/tools/pipeline/service/module_pipeline_master.cpp index 4b1f77bf4..e57f7b01f 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_master.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_master.cpp @@ -170,6 +170,9 @@ public: g_IsMaster = false; + nldebug("Wait for tasks on the master"); + while (m_TaskManager->getNumWaitingTasks() > 0) + nlSleep(10); delete m_TaskManager; m_TaskManager = NULL; @@ -523,6 +526,7 @@ public: nlwarning("Slave disconnected before callback could be delivered"); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_MASTER_UPDATE_DATABASE_FOR_SLAVE); CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_CB_GONE); + Master->m_SlavesMutex.unlock(); delete this; return; } @@ -589,8 +593,15 @@ public: if (ok) { - CUpdateDatabaseStatusByVectorTask *slaveTask = new CUpdateDatabaseStatusByVectorTask(this, sender, slave->Vector); // slave->Vector is wiped due to swap - m_TaskManager->addTask(slaveTask); + if (g_IsExiting) + { + nlwarning("Cannot add task while exiting"); + } + else + { + CUpdateDatabaseStatusByVectorTask *slaveTask = new CUpdateDatabaseStatusByVectorTask(this, sender, slave->Vector); // slave->Vector is wiped due to swap + m_TaskManager->addTask(slaveTask); + } } } diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 4e59b39c3..16a1749b9 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -125,9 +125,15 @@ public: // TODO? // wait till build task has exited if still was running // wait for other things to exist in case there are... + nldebug("Wait for tasks on the slave"); + while (m_TaskManager->getNumWaitingTasks() > 0) + nlSleep(10); delete m_TaskManager; m_TaskManager = NULL; + if (m_AbortRequested) + finalizeAbort(); // hopefully this is fine + // temp sanity nlassert(m_ActiveProject == NULL); nlassert(m_ActiveProcess == NULL);