AP_HAL_SITL: remove race in SITL::UARTDriver::_write

txspace could change if another thread is involved
This commit is contained in:
Peter Barker 2023-07-13 16:14:27 +10:00 committed by Andrew Tridgell
parent 4f69f9cc23
commit efc7b4b6ee
1 changed files with 3 additions and 2 deletions

View File

@ -256,8 +256,9 @@ void UARTDriver::_flush(void)
size_t UARTDriver::_write(const uint8_t *buffer, size_t size)
{
if (txspace() <= size) {
size = txspace();
const auto _txspace = txspace();
if (_txspace < size) {
size = _txspace;
}
if (size <= 0) {
return 0;