AP_Logger: add a semaphore to protect creation of new log formats

This commit is contained in:
Andrew Tridgell 2020-01-16 10:16:25 +11:00
parent 184b3e1d63
commit 43c99664b0
2 changed files with 3 additions and 0 deletions

View File

@ -855,6 +855,8 @@ void AP_Logger::assert_same_fmt_for_name(const AP_Logger::log_write_fmt *f,
AP_Logger::log_write_fmt *AP_Logger::msg_fmt_for_name(const char *name, const char *labels, const char *units, const char *mults, const char *fmt)
{
WITH_SEMAPHORE(log_write_fmts_sem);
struct log_write_fmt *f;
for (f = log_write_fmts; f; f=f->next) {
if (f->name == name) { // ptr comparison

View File

@ -413,6 +413,7 @@ private:
const char *units;
const char *mults;
} *log_write_fmts;
HAL_Semaphore_Recursive log_write_fmts_sem;
// return (possibly allocating) a log_write_fmt for a name
struct log_write_fmt *msg_fmt_for_name(const char *name, const char *labels, const char *units, const char *mults, const char *fmt);