Skip to content

Commit 34d5612

Browse files
committed
pbsys/program_stop: Remove shutdown one-shot.
Since the program stop just schedules something, this does not need to be protected by a one-shot. In fact, this is slightly safer because the mp_pending_exception could theoretically be overwritten by something other than SystemAbort before it gets handled by the VM. Now it will just keep scheduling the SystemAbort.
1 parent 71157b1 commit 34d5612

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

lib/pbio/sys/program_stop.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
static pbio_button_flags_t stop_buttons = PBIO_BUTTON_CENTER;
1717
// State for button press one-shot
1818
static bool stop_button_pressed;
19-
// State for shutdown request one-shot
20-
static bool program_stop_on_shutdown_requested;
2119

2220
/**
2321
* Request the user program to stop. For example, in MicroPython, this may raise
@@ -48,12 +46,8 @@ void pbsys_program_stop_set_buttons(pbio_button_flags_t buttons) {
4846
void pbsys_program_stop_poll(void) {
4947

5048
// Cancel user application program if shutdown was requested.
51-
if (program_stop_on_shutdown_requested) {
52-
// Should not request stop more than once.
53-
return;
54-
} else if (pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST)) {
49+
if (pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST)) {
5550
pbsys_program_stop(true);
56-
program_stop_on_shutdown_requested = true;
5751
return;
5852
}
5953

0 commit comments

Comments
 (0)