Skip to content

Commit

Permalink
Fix race condition in _xtimer_set_absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
samkumar committed Apr 19, 2017
1 parent 2e6520d commit d163e8a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sys/xtimer/xtimer_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,22 @@ static inline void _lltimer_set(uint32_t target)

int _xtimer_set_absolute(xtimer_t *timer, uint32_t target)
{
uint32_t now = _xtimer_now();
uint32_t now;
int res = 0;

DEBUG("timer_set_absolute(): now=%" PRIu32 " target=%" PRIu32 "\n", now, target);

unsigned state = irq_disable();
timer->next = NULL;
now = _xtimer_now();
if ((target >= now) && ((target - XTIMER_BACKOFF) < now)) {
irq_restore(state);
/* backoff */
xtimer_spin_until(target + XTIMER_BACKOFF);
_shoot(timer);
return 0;
}

unsigned state = irq_disable();
if (_is_set(timer)) {
_remove(timer);
}
Expand Down

0 comments on commit d163e8a

Please sign in to comment.