Fix SerialUART::overflow reporting race condition (#1133)

Fixes #1132
This commit was merged in pull request #1133.
This commit is contained in:
Earle F. Philhower, III
2023-01-21 01:38:15 -08:00
committed by GitHub
parent d619bf0bc1
commit ecaa2bd778
+13 -4
View File
@@ -289,13 +289,22 @@ int SerialUART::read() {
}
bool SerialUART::overflow() {
CoreMutex m(&_mutex);
if (!_running || !m) {
if (!_running) {
return false;
}
bool hold = _overflow;
if (_polling) {
_handleIRQ(false);
} else {
_pumpFIFO();
}
mutex_enter_blocking(&_fifoMutex);
bool ovf = _overflow;
_overflow = false;
return hold;
mutex_exit(&_fifoMutex);
return ovf;
}
int SerialUART::available() {