diff options
| author | Jeff Epler <jepler@gmail.com> | 2020-07-20 08:44:39 -0500 |
|---|---|---|
| committer | Jeff Epler <jepler@gmail.com> | 2020-07-20 08:44:39 -0500 |
| commit | db43c56f794508689b07d931c16cadd3e98aad87 (patch) | |
| tree | 5d0ef4e61e9452e58f15fa501720ac190fe9a5d6 | |
| parent | 8f928340c68fc5ef590546039b0a3db44502415b (diff) | |
background callbacks: Clear any callbacks that were queued
Before this, a background callback that was on the list when
background_callback_reset was called could have ended up in a state
that made it "un-queueable": its "prev" pointer could have been non-NULL.
| -rw-r--r-- | supervisor/shared/background_callback.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c index d10579c4f..8e12dd362 100644 --- a/supervisor/shared/background_callback.c +++ b/supervisor/shared/background_callback.c @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#include <string.h> + #include "py/gc.h" #include "py/mpconfig.h" #include "supervisor/background_callback.h" @@ -101,6 +103,12 @@ void background_callback_end_critical_section() { void background_callback_reset() { CALLBACK_CRITICAL_BEGIN; + background_callback_t *cb = (background_callback_t*)callback_head; + while(cb) { + background_callback_t *next = cb->next; + memset(cb, 0, sizeof(*cb)); + cb = next; + } callback_head = NULL; callback_tail = NULL; in_background_callback = false; |
