altos: Make ao_delay(0) not wait forever
authorKeith Packard <keithp@keithp.com>
Wed, 29 Jun 2016 19:52:37 +0000 (12:52 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 30 Jun 2016 02:17:45 +0000 (19:17 -0700)
ao_delay() is implemented on top of ao_sleep_for, and ao_sleep_for
uses the timeout value of 0 to indicate an infinite timeout. Calls to
ao_delay for 0 ticks would unintentionally hit this case and end up
waiting forever.x

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao_task.c

index 47352fc104afde937559c9ee2a31060447c62c95..0a790ccd1e44c18c1d69715b3bc8ee3e800730bc 100644 (file)
@@ -504,6 +504,8 @@ static __xdata uint8_t ao_forever;
 void
 ao_delay(uint16_t ticks)
 {
+       if (!ticks)
+               ticks = 1;
        ao_sleep_for(&ao_forever, ticks);
 }