Skip to content

Commit f9752f9

Browse files
committed
events - Fixed overflow of timeout on STM32F4
For equeue_sema_wait, -1 is used to indicate an infinite wait. This wasn't handled in the nonrtos implementation and caused undefined/weird behaviour after an overflow on integer multiplication. On most boards, the infinite wait would return after ~50 days, on the STM32F4 the timeout killed all other timeouts for some reason.
1 parent 4f9e9f6 commit f9752f9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

events/equeue/equeue_mbed.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ static void equeue_sema_timeout(equeue_sema_t *s) {
124124
bool equeue_sema_wait(equeue_sema_t *s, int ms) {
125125
int signal = 0;
126126
Timeout timeout;
127-
timeout.attach_us(s, equeue_sema_timeout, ms*1000);
127+
if (ms > 0) {
128+
timeout.attach_us(callback(equeue_sema_timeout, s), ms*1000);
129+
}
128130

129131
core_util_critical_section_enter();
130132
while (!*s) {

0 commit comments

Comments
 (0)