Skip to content

Commit

Permalink
events - Fixed overflow of timeout on STM32F4
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geky committed Aug 4, 2019
1 parent b6168bf commit 56b841d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion equeue_mbed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ static void equeue_sema_timeout(equeue_sema_t *s) {
bool equeue_sema_wait(equeue_sema_t *s, int ms) {
int signal = 0;
Timeout timeout;
timeout.attach_us(s, equeue_sema_timeout, ms*1000);
if (ms > 0) {
timeout.attach_us(callback(equeue_sema_timeout, s), ms*1000);
}

core_util_critical_section_enter();
while (!*s) {
Expand Down

0 comments on commit 56b841d

Please sign in to comment.