mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 01:43:33 +08:00
fix infinite loop when not logging
This commit is contained in:
committed by
Lorenz Meier
parent
f40afac448
commit
26596dbe15
@@ -103,21 +103,20 @@ void *LogWriter::run_helper(void *context)
|
|||||||
|
|
||||||
void LogWriter::run()
|
void LogWriter::run()
|
||||||
{
|
{
|
||||||
// Wait for _should_run flag
|
|
||||||
while (!_exit_thread) {
|
|
||||||
bool start = false;
|
|
||||||
pthread_mutex_lock(&_mtx);
|
|
||||||
pthread_cond_wait(&_cv, &_mtx);
|
|
||||||
start = _should_run;
|
|
||||||
pthread_mutex_unlock(&_mtx);
|
|
||||||
|
|
||||||
if (start) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!_exit_thread) {
|
while (!_exit_thread) {
|
||||||
// Outer endless loop
|
// Outer endless loop
|
||||||
|
// Wait for _should_run flag
|
||||||
|
while (!_exit_thread) {
|
||||||
|
bool start = false;
|
||||||
|
pthread_mutex_lock(&_mtx);
|
||||||
|
pthread_cond_wait(&_cv, &_mtx);
|
||||||
|
start = _should_run;
|
||||||
|
pthread_mutex_unlock(&_mtx);
|
||||||
|
|
||||||
|
if (start) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int poll_count = 0;
|
int poll_count = 0;
|
||||||
int written = 0;
|
int written = 0;
|
||||||
@@ -196,7 +195,6 @@ void LogWriter::run()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user