mirror of https://github.com/ArduPilot/ardupilot
AP_Logger: take a blocking semaphore when writing messages using the block logger
This commit is contained in:
parent
9044b72a68
commit
43262ee036
|
@ -137,10 +137,7 @@ bool AP_Logger_Block::_WritePrioritisedBlock(const void *pBuffer, uint16_t size,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!write_sem.take(1)) {
|
WITH_SEMAPHORE(write_sem);
|
||||||
_dropped++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const uint32_t space = writebuf.space();
|
const uint32_t space = writebuf.space();
|
||||||
|
|
||||||
|
@ -155,7 +152,6 @@ bool AP_Logger_Block::_WritePrioritisedBlock(const void *pBuffer, uint16_t size,
|
||||||
if (!must_dribble &&
|
if (!must_dribble &&
|
||||||
space < non_messagewriter_message_reserved_space(writebuf.get_size())) {
|
space < non_messagewriter_message_reserved_space(writebuf.get_size())) {
|
||||||
// this message isn't dropped, it will be sent again...
|
// this message isn't dropped, it will be sent again...
|
||||||
write_sem.give();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
last_messagewrite_message_sent = now;
|
last_messagewrite_message_sent = now;
|
||||||
|
@ -163,7 +159,6 @@ bool AP_Logger_Block::_WritePrioritisedBlock(const void *pBuffer, uint16_t size,
|
||||||
// we reserve some amount of space for critical messages:
|
// we reserve some amount of space for critical messages:
|
||||||
if (!is_critical && space < critical_message_reserved_space(writebuf.get_size())) {
|
if (!is_critical && space < critical_message_reserved_space(writebuf.get_size())) {
|
||||||
_dropped++;
|
_dropped++;
|
||||||
write_sem.give();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,13 +166,11 @@ bool AP_Logger_Block::_WritePrioritisedBlock(const void *pBuffer, uint16_t size,
|
||||||
// if no room for entire message - drop it:
|
// if no room for entire message - drop it:
|
||||||
if (space < size) {
|
if (space < size) {
|
||||||
_dropped++;
|
_dropped++;
|
||||||
write_sem.give();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
writebuf.write((uint8_t*)pBuffer, size);
|
writebuf.write((uint8_t*)pBuffer, size);
|
||||||
df_stats_gather(size, writebuf.space());
|
df_stats_gather(size, writebuf.space());
|
||||||
write_sem.give();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue