don't call reload_initiate if already initiated

This commit is contained in:
MicroDev 2023-03-21 21:34:30 +05:30
parent 7ee3f30c17
commit e4b5b20ebe
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730

View File

@ -82,7 +82,10 @@ inline bool autoreload_is_enabled() {
} }
void autoreload_trigger() { void autoreload_trigger() {
if (autoreload_enabled & !autoreload_suspended) { if (!autoreload_enabled || autoreload_suspended != 0) {
return;
}
bool reload_initiated = autoreload_pending();
last_autoreload_trigger = supervisor_ticks_ms32(); last_autoreload_trigger = supervisor_ticks_ms32();
// Guard against the rare time that ticks is 0; // Guard against the rare time that ticks is 0;
if (last_autoreload_trigger == 0) { if (last_autoreload_trigger == 0) {
@ -91,6 +94,7 @@ void autoreload_trigger() {
// Initiate a reload of the VM immediately. Later code will pause to // Initiate a reload of the VM immediately. Later code will pause to
// wait for the autoreload to become ready. Doing the VM exit // wait for the autoreload to become ready. Doing the VM exit
// immediately is clearer for the user. // immediately is clearer for the user.
if (!reload_initiated) {
reload_initiate(RUN_REASON_AUTO_RELOAD); reload_initiate(RUN_REASON_AUTO_RELOAD);
} }
} }
@ -111,5 +115,5 @@ bool autoreload_ready() {
} }
bool autoreload_pending(void) { bool autoreload_pending(void) {
return last_autoreload_trigger != 0; return last_autoreload_trigger > 0;
} }