summaryrefslogtreecommitdiff
path: root/src/ao_packet_master.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-08-29 23:22:27 -0700
committerKeith Packard <keithp@keithp.com>2010-08-29 23:22:27 -0700
commit63c832394a829f41b8f77d075786530536360349 (patch)
tree794b3f9f02c66434497cf68d49e06d7ae985b29c /src/ao_packet_master.c
parent43619c13f749b79c096d1e8fdab3d5cfb5fd85f1 (diff)
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 <keithp@keithp.com>
Diffstat (limited to 'src/ao_packet_master.c')
-rw-r--r--src/ao_packet_master.c9
1 files changed, 5 insertions, 4 deletions
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));
}
}