Skip to content

Commit

Permalink
Fixes another (smaller) race condition in ESP32's select wakeup.
Browse files Browse the repository at this point in the history
The wakeup_from_isr routine consults the pendingWakeup_ and inSelect_ variables.
These variables need to be locked, because multi-core ESP32's could run an isr
on one core and othercode on a different core.

Moves the atomic lock from esp_wakeup_from_isr into OSSelectWakeup::wakeup_from_isr.
  • Loading branch information
balazsracz committed Feb 3, 2024
1 parent da3ee31 commit a386fcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/os/OSSelectWakeup.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ void OSSelectWakeup::esp_wakeup()
/// call from within an ISR context.
void OSSelectWakeup::esp_wakeup_from_isr()
{
AtomicHolder h(this);
BaseType_t woken = pdFALSE;

// If our VFS FD is not set in the except fd_set we can exit early.
Expand Down
4 changes: 4 additions & 0 deletions src/os/OSSelectWakeup.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ public:
#if OPENMRN_FEATURE_RTOS_FROM_ISR
void wakeup_from_isr()
{
#if defined(ESP_PLATFORM)
// On multi-core ESP32s we need to lock objects even in ISRs.
AtomicHolder h(this);
#endif
pendingWakeup_ = true;
if (inSelect_)
{
Expand Down

0 comments on commit a386fcc

Please sign in to comment.