Protect logstream startup entries with a mutex
This commit is contained in:
+21
-15
@@ -425,8 +425,11 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_startupLogging = on;
|
{
|
||||||
m_startupEntries.clear();
|
SGGuard<SGMutex> g(m_lock);
|
||||||
|
m_startupLogging = on;
|
||||||
|
m_startupEntries.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void run()
|
virtual void run()
|
||||||
@@ -438,13 +441,14 @@ public:
|
|||||||
if ((entry.debugClass == SG_NONE) && !strcmp(entry.file, "done")) {
|
if ((entry.debugClass == SG_NONE) && !strcmp(entry.file, "done")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
if (m_startupLogging) {
|
SGGuard<SGMutex> g(m_lock);
|
||||||
// save to the startup list for not-yet-added callbacks to
|
if (m_startupLogging) {
|
||||||
// pull down on startup
|
// save to the startup list for not-yet-added callbacks to
|
||||||
m_startupEntries.push_back(entry);
|
// pull down on startup
|
||||||
|
m_startupEntries.push_back(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// submit to each installed callback in turn
|
// submit to each installed callback in turn
|
||||||
for (simgear::LogCallback* cb : m_callbacks) {
|
for (simgear::LogCallback* cb : m_callbacks) {
|
||||||
(*cb)(entry.debugClass, entry.debugPriority,
|
(*cb)(entry.debugClass, entry.debugPriority,
|
||||||
@@ -455,14 +459,16 @@ public:
|
|||||||
|
|
||||||
bool stop()
|
bool stop()
|
||||||
{
|
{
|
||||||
SGGuard<SGMutex> g(m_lock);
|
{
|
||||||
if (!m_isRunning) {
|
SGGuard<SGMutex> g(m_lock);
|
||||||
return false;
|
if (!m_isRunning) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// log a special marker value, which will cause the thread to wakeup,
|
// log a special marker value, which will cause the thread to wakeup,
|
||||||
// and then exit
|
// and then exit
|
||||||
log(SG_NONE, SG_ALERT, "done", -1, "");
|
log(SG_NONE, SG_ALERT, "done", -1, "");
|
||||||
|
}
|
||||||
join();
|
join();
|
||||||
|
|
||||||
m_isRunning = false;
|
m_isRunning = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user