From: Keith Packard Date: Mon, 30 Aug 2010 06:22:27 +0000 (-0700) Subject: altos: shut down packet mode cleanly X-Git-Tag: debian/0.7+22+g4790f78~14 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=63c832394a829f41b8f77d075786530536360349 altos: shut down packet mode cleanly Instead of constantly bashing the packet master thread, let it shut itself down in an orderly fashion. It will shut down fairly quickly as all of the activities in that thread are bounded. Otherwise, the master packet thread might leave mutexes locked and all sorts of other horrors. Tested on Linux and Mac OS X and shown to be reliable. Signed-off-by: Keith Packard --- diff --git a/src/ao_packet_master.c b/src/ao_packet_master.c index 50f5aeff..641b49f4 100644 --- a/src/ao_packet_master.c +++ b/src/ao_packet_master.c @@ -29,6 +29,8 @@ ao_packet_getchar(void) __critical ao_wake_task(&ao_packet_task); ao_usb_flush(); ao_sleep(&ao_stdin_ready); + if (!ao_packet_enable) + break; } return c; } @@ -127,10 +129,9 @@ ao_packet_forward(void) __reentrant ao_delay(AO_MS_TO_TICKS(100)); ao_packet_enable = 0; while (ao_packet_echo_task.wchan || ao_packet_task.wchan) { - ao_radio_abort(); - ao_wake_task(&ao_packet_echo_task); - ao_wake_task(&ao_packet_task); - ao_yield(); + if (ao_packet_echo_task.wchan) + ao_wake_task(&ao_packet_echo_task); + ao_delay(AO_MS_TO_TICKS(10)); } }