Send tmrCOMMAND_START_DONT_TRACE to front

When reloading an auto-reload timer, the timer task sends the
tmrCOMMAND_START_DONT_TRACE command if the new timer period has already
elapsed.

If the command queue already contains a stop or delete command for the
timer, then prior to this commit the tmrCOMMAND_START_DONT_TRACE command
is processed *after* the stop or delete command.  Consequently the timer
is restarted unexpectedly (in the stop case) or uses freed memory (in
the delete case).  After this commit, the tmrCOMMAND_START_DONT_TRACE
command is processed before the stop or delete command.
This commit is contained in:
Jeff Tenney 2021-04-06 14:28:33 -07:00
parent b08c19f745
commit e2235a695e

View file

@ -395,7 +395,18 @@
{
if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING )
{
xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );
/* The "start don't trace" command comes only from the timer
* task itself. This command must be executed before any other
* commands now in the queue for this timer, in case one of
* those commands is stop or delete. */
if( xCommandID == tmrCOMMAND_START_DONT_TRACE )
{
xReturn = xQueueSendToFront( xTimerQueue, &xMessage, xTicksToWait );
}
else
{
xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );
}
}
else
{