Fix race condition in SoftwareSerial::overflow()

If an interrupt causing overflow would occur between reading
_buffer_overflow and clearing it, this overflow condition would be
immediately cleared and never be returned by overflow().

By only clearing the overflow flag if an overflow actually occurred,
this problem goes away (worst case overflow() returns false even though
an overflow _just_ occurred, but then the next call to overflow() will
return true).
This commit is contained in:
Matthijs Kooijman 2013-06-13 09:56:46 +02:00
parent cb36793486
commit 11ade32f20
1 changed files with 1 additions and 1 deletions

View File

@ -88,7 +88,7 @@ public:
void end();
bool isListening() { return this == active_object; }
bool stopListening();
bool overflow() { bool ret = _buffer_overflow; _buffer_overflow = false; return ret; }
bool overflow() { bool ret = _buffer_overflow; if (ret) _buffer_overflow = false; return ret; }
int peek();
virtual size_t write(uint8_t byte);