From ced09400f9adb7170fbb83ad7564a28adf7cb1e3 Mon Sep 17 00:00:00 2001 From: Morgan Hughes Date: Sat, 9 Jul 2022 10:55:55 -0700 Subject: [PATCH] Make pollcat_loop_exit() a oneshot --- include/pollcat/struct.h | 8 +++++++- src/struct.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/pollcat/struct.h b/include/pollcat/struct.h index 38e044e..f820b35 100644 --- a/include/pollcat/struct.h +++ b/include/pollcat/struct.h @@ -95,7 +95,13 @@ struct pollcat *pollcat_iter_next (void); int pollcat_loop (int *poll_ret); -/** Cause pollcat_loop() to return 0 on its next call +/** Cause pollcat_loop() to return 0 on its next call only + * + * \note Each call of pollcat_loop_exit() causes pollcat_loop() to return 0 once; + * pollcat_loop() then resets the flag to return nonzero until the next time + * pollcat_loop_exit() has been called. This allows the entire main loop to be + * wrapped in an outer loop so tasks like updating firmware can be done without + * affecting the pollcat loop. */ void pollcat_loop_exit (void); diff --git a/src/struct.c b/src/struct.c index 0008e11..1f6d737 100644 --- a/src/struct.c +++ b/src/struct.c @@ -132,7 +132,10 @@ int pollcat_loop (int *poll_ret) /* check whether pollcat_loop_exit() has been called, and return 0 if so */ if ( pollcat_loop_stop ) + { + pollcat_loop_stop = 0; return 0; + } /* call pollcat_timer_reduce_timeout() to improve timer latency */ pollcat_timer_reduce_timeout();