Forráskód Böngészése

Prevent re-entry in EOF command processing

cmdqueue will run commands when EOF is reached without returning to the
main loop, which is already incorrect.

However, since it needs to ensure the queue is empty, an st_synchronize
call can result in a re-entrant call to get_command, which will
reprocess EOF again. Even if we removed st_synchronize, another command
could be picked by an unsuspecting manage_inactivity() somewhere else.

Short-circuit EOF processing by closing the file early and checking for
the file state early in get_command.

This should fix #3549
Yuri D'Elia 2 éve
szülő
commit
c0b5fea525
1 módosított fájl, 5 hozzáadás és 1 törlés
  1. 5 1
      Firmware/cmdqueue.cpp

+ 5 - 1
Firmware/cmdqueue.cpp

@@ -534,7 +534,7 @@ void get_command()
     }
     }
 
 
   #ifdef SDSUPPORT
   #ifdef SDSUPPORT
-  if(!card.sdprinting || serial_count!=0){
+  if(!card.sdprinting || !card.isFileOpen() || serial_count!=0){
     // If there is a half filled buffer from serial line, wait until return before
     // If there is a half filled buffer from serial line, wait until return before
     // continuing with the serial line.
     // continuing with the serial line.
      return;
      return;
@@ -631,6 +631,10 @@ void get_command()
       // cleared by printingHasFinished after peforming all remaining moves.
       // cleared by printingHasFinished after peforming all remaining moves.
       if(!cmdqueue_calc_sd_length())
       if(!cmdqueue_calc_sd_length())
       {
       {
+          // queue is complete, but before we process EOF commands prevent
+          // re-entry by disabling SD processing from any st_synchronize call
+          card.closefile();
+
           SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED
           SERIAL_PROTOCOLLNRPGM(_n("Done printing file"));////MSG_FILE_PRINTED
           stoptime=_millis();
           stoptime=_millis();
           char time[30];
           char time[30];