Skip to content

Commit db43c56

Browse files
committed
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.
1 parent 8f92834 commit db43c56

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

supervisor/shared/background_callback.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#include <string.h>
28+
2729
#include "py/gc.h"
2830
#include "py/mpconfig.h"
2931
#include "supervisor/background_callback.h"
@@ -101,6 +103,12 @@ void background_callback_end_critical_section() {
101103

102104
void background_callback_reset() {
103105
CALLBACK_CRITICAL_BEGIN;
106+
background_callback_t *cb = (background_callback_t*)callback_head;
107+
while(cb) {
108+
background_callback_t *next = cb->next;
109+
memset(cb, 0, sizeof(*cb));
110+
cb = next;
111+
}
104112
callback_head = NULL;
105113
callback_tail = NULL;
106114
in_background_callback = false;

0 commit comments

Comments
 (0)