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
This commit is contained in:
parent
8e72470afc
commit
c0b5fea525
@ -534,7 +534,7 @@ void get_command()
|
||||
}
|
||||
|
||||
#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
|
||||
// continuing with the serial line.
|
||||
return;
|
||||
@ -631,6 +631,10 @@ void get_command()
|
||||
// cleared by printingHasFinished after peforming all remaining moves.
|
||||
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
|
||||
stoptime=_millis();
|
||||
char time[30];
|
||||
|
Loading…
Reference in New Issue
Block a user