Skip to content

Commit

Permalink
Fixes nasa#274, NumOfChildTasks not decremented
Browse files Browse the repository at this point in the history
  • Loading branch information
dmknutsen committed Jan 21, 2020
1 parent 2b27dfc commit 8ed0dca
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
28 changes: 24 additions & 4 deletions fsw/cfe-core/src/es/cfe_es_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,8 @@ int32 CFE_ES_DeleteChildTask(uint32 OSTaskId)
bool TaskIsMain = false;
int32 ReturnCode = CFE_SUCCESS;
int32 OSReturnCode;

int32 Result = CFE_SUCCESS;
uint32 AppId= 0xFFFFFFFF;

/*
** Make sure the task ID is within range
Expand Down Expand Up @@ -1224,16 +1225,34 @@ int32 CFE_ES_DeleteChildTask(uint32 OSTaskId)
if ( OSReturnCode == OS_SUCCESS )
{
/*
** Get the AppID of the calling Application
*/
Result = CFE_ES_GetAppIDInternal(&AppId);
if (Result != CFE_SUCCESS)
{
CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask: Error calling CFE_ES_GetAppIDInternal for Task '%d'. RC = 0x%08X\n",(int)TaskId,(unsigned int)Result);
ReturnCode = CFE_ES_ERR_CHILD_TASK_DELETE;
}
else /* else AppId is valid */
{
/*
** Decrement the "Registered" child task count for the App
*/
if (CFE_ES_Global.AppTable[AppId].TaskInfo.NumOfChildTasks != 0 )
{
CFE_ES_Global.AppTable[AppId].TaskInfo.NumOfChildTasks --;
}
ReturnCode = CFE_SUCCESS;
}
/*
** Invalidate the task table entry
*/
CFE_ES_Global.TaskTable[TaskId].RecordUsed = false;
CFE_ES_Global.RegisteredTasks--;

/*
** Report the task delete
*/
CFE_ES_SysLogWrite_Unsync("CFE_ES_DeleteChildTask Task %u Deleted\n",(unsigned int)OSTaskId );
ReturnCode = CFE_SUCCESS;
}
else
{
Expand Down Expand Up @@ -1275,7 +1294,8 @@ int32 CFE_ES_DeleteChildTask(uint32 OSTaskId)
}
return(ReturnCode);

} /* End of CFE_ES_DeleteTask() */
} /* End of CFE_ES_DeleteChildTask() */


/*
** Function: CFE_ES_ExitChildTask
Expand Down
12 changes: 10 additions & 2 deletions fsw/cfe-core/unit-test/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -4798,9 +4798,17 @@ void TestAPI(void)
CFE_ES_Global.AppTable[0].TaskInfo.MainTaskId = 15;
OS_TaskCreate(&CFE_ES_Global.TaskTable[1].TaskId, NULL, NULL, NULL,
0, 0, 0);
uint32 NumOchildTasks = CFE_ES_Global.AppTable[0].TaskInfo.NumOfChildTasks;
uint32 NumORegTasks = CFE_ES_Global.RegisteredTasks;
int32 DeleteChildResult = CFE_ES_DeleteChildTask(CFE_ES_Global.TaskTable[1].TaskId);
int32 DeleteChildTestResult = 0xFFFFFFFF;
if( DeleteChildResult == CFE_SUCCESS && CFE_ES_Global.AppTable[0].TaskInfo.NumOfChildTasks ==
NumOchildTasks - 1 && CFE_ES_Global.RegisteredTasks == NumORegTasks - 1 )
{
DeleteChildTestResult = CFE_SUCCESS;
}
UT_Report(__FILE__, __LINE__,
CFE_ES_DeleteChildTask(CFE_ES_Global.TaskTable[1].TaskId) ==
CFE_SUCCESS,
DeleteChildTestResult == CFE_SUCCESS,
"CFE_ES_DeleteChildTask",
"Delete child task successful");

Expand Down

0 comments on commit 8ed0dca

Please sign in to comment.