Skip to content

Commit 7f18938

Browse files
author
Donatien Garnier
committed
Fix potential race condition in nRF5xn.cpp
1 parent d1ba108 commit 7f18938

File tree

1 file changed

+6
-1
lines changed
  • features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source

1 file changed

+6
-1
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5x/source/nRF5xn.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ nRF5xn::waitForEvent(void)
222222
}
223223

224224
void nRF5xn::processEvents() {
225-
if (isEventsSignaled) {
225+
core_util_critical_section_enter();
226+
while (isEventsSignaled) {
226227
isEventsSignaled = false;
228+
core_util_critical_section_exit();
227229
#if NRF_SD_BLE_API_VERSION >= 5
228230
// We use the "polling" dispatch model
229231
// http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__nrf__sdh.html?cp=4_0_0_6_11_60_20#gab4d7be69304d4f5feefd1d440cc3e6c7
@@ -232,5 +234,8 @@ void nRF5xn::processEvents() {
232234
#else
233235
intern_softdevice_events_execute();
234236
#endif
237+
238+
core_util_critical_section_enter();
235239
}
240+
core_util_critical_section_exit();
236241
}

0 commit comments

Comments
 (0)