Skip to content

Commit

Permalink
Fix #471, order of operations for delete all
Browse files Browse the repository at this point in the history
When cleaning up for shutdown, delete resources that have
a task/thread first, followed by other resource types.

This helps avoid possible dependencies as running threads
might be using the other resources.
  • Loading branch information
jphickey committed Dec 28, 2020
1 parent d698a4d commit b5863b7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/os/shared/src/osapi-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,18 @@ void OS_DeleteAllObjects(void)
{
ObjectCount = 0;
++TryCount;

/* Delete timers and tasks first, as they could be actively using other object types */
OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TIMECB, OS_OBJECT_CREATOR_ANY,
OS_CleanUpObject, &ObjectCount);
OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TIMEBASE, OS_OBJECT_CREATOR_ANY,
OS_CleanUpObject, &ObjectCount);
OS_ForEachObjectOfType(OS_OBJECT_TYPE_OS_TASK, OS_OBJECT_CREATOR_ANY,
OS_CleanUpObject, &ObjectCount);

/* Then try to delete all other remaining objects of any type */
OS_ForEachObject(OS_OBJECT_CREATOR_ANY, OS_CleanUpObject, &ObjectCount);

if (ObjectCount == 0 || TryCount > 4)
{
break;
Expand Down

0 comments on commit b5863b7

Please sign in to comment.