Changed: #1440 Handle more exit cases

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 12 years ago
parent 6e8a115eb3
commit cae3ef87cd

@ -414,7 +414,7 @@ void updatePathStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, cons
void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, const std::string &dir, bool recurse) 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."); nlerror("Not master, not allowed.");
} }

@ -170,6 +170,9 @@ public:
g_IsMaster = false; g_IsMaster = false;
nldebug("Wait for tasks on the master");
while (m_TaskManager->getNumWaitingTasks() > 0)
nlSleep(10);
delete m_TaskManager; delete m_TaskManager;
m_TaskManager = NULL; m_TaskManager = NULL;
@ -523,6 +526,7 @@ public:
nlwarning("Slave disconnected before callback could be delivered"); nlwarning("Slave disconnected before callback could be delivered");
CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_MASTER_UPDATE_DATABASE_FOR_SLAVE); CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_MASTER_UPDATE_DATABASE_FOR_SLAVE);
CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_CB_GONE); CInfoFlags::getInstance()->addFlag(PIPELINE_INFO_SLAVE_CB_GONE);
Master->m_SlavesMutex.unlock();
delete this; delete this;
return; return;
} }
@ -589,8 +593,15 @@ public:
if (ok) if (ok)
{ {
CUpdateDatabaseStatusByVectorTask *slaveTask = new CUpdateDatabaseStatusByVectorTask(this, sender, slave->Vector); // slave->Vector is wiped due to swap if (g_IsExiting)
m_TaskManager->addTask(slaveTask); {
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);
}
} }
} }

@ -125,9 +125,15 @@ public:
// TODO? // TODO?
// wait till build task has exited if still was running // wait till build task has exited if still was running
// wait for other things to exist in case there are... // 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; delete m_TaskManager;
m_TaskManager = NULL; m_TaskManager = NULL;
if (m_AbortRequested)
finalizeAbort(); // hopefully this is fine
// temp sanity // temp sanity
nlassert(m_ActiveProject == NULL); nlassert(m_ActiveProject == NULL);
nlassert(m_ActiveProcess == NULL); nlassert(m_ActiveProcess == NULL);

Loading…
Cancel
Save