Skip to content

Commit

Permalink
Fix nasa#1952, patch for recursive event loop
Browse files Browse the repository at this point in the history
Adds CFE_SB_RequestToSendEvent/CFE_SB_FinishSendEvent wrappers around
all events generated by CFE_SB_TransmitMsgValidate.  This is avoids
the potential for a recursive loop if configured improperly.
  • Loading branch information
jphickey committed Sep 29, 2021
1 parent 64a6a59 commit efe8e74
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
42 changes: 30 additions & 12 deletions modules/sb/fsw/src/cfe_sb_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,24 +1503,42 @@ int32 CFE_SB_TransmitMsgValidate(const CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t
switch (PendingEventID)
{
case CFE_SB_SEND_BAD_ARG_EID:
CFE_EVS_SendEventWithAppID(CFE_SB_SEND_BAD_ARG_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Send Err:Bad input argument,Arg 0x%lx,App %s", (unsigned long)MsgPtr,
CFE_SB_GetAppTskName(TskId, FullName));
if (CFE_SB_RequestToSendEvent(TskId, CFE_SB_SEND_BAD_ARG_EID_BIT) == CFE_SB_GRANTED)
{
CFE_EVS_SendEventWithAppID(CFE_SB_SEND_BAD_ARG_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Send Err:Bad input argument,Arg 0x%lx,App %s", (unsigned long)MsgPtr,
CFE_SB_GetAppTskName(TskId, FullName));

/* clear the bit so the task may send this event again */
CFE_SB_FinishSendEvent(TskId, CFE_SB_SEND_BAD_ARG_EID_BIT);
}
break;

case CFE_SB_SEND_INV_MSGID_EID:
CFE_EVS_SendEventWithAppID(CFE_SB_SEND_INV_MSGID_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Send Err:Invalid MsgId(0x%x)in msg,App %s",
(unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr),
CFE_SB_GetAppTskName(TskId, FullName));
if (CFE_SB_RequestToSendEvent(TskId, CFE_SB_SEND_INV_MSGID_EID_BIT) == CFE_SB_GRANTED)
{
CFE_EVS_SendEventWithAppID(CFE_SB_SEND_INV_MSGID_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Send Err:Invalid MsgId(0x%x)in msg,App %s",
(unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr),
CFE_SB_GetAppTskName(TskId, FullName));

/* clear the bit so the task may send this event again */
CFE_SB_FinishSendEvent(TskId, CFE_SB_SEND_INV_MSGID_EID_BIT);
}
break;

case CFE_SB_MSG_TOO_BIG_EID:
CFE_EVS_SendEventWithAppID(CFE_SB_MSG_TOO_BIG_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Send Err:Msg Too Big MsgId=0x%x,app=%s,size=%d,MaxSz=%d",
(unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr),
CFE_SB_GetAppTskName(TskId, FullName), (int)*SizePtr,
CFE_MISSION_SB_MAX_SB_MSG_SIZE);
if (CFE_SB_RequestToSendEvent(TskId, CFE_SB_MSG_TOO_BIG_EID_BIT) == CFE_SB_GRANTED)
{
CFE_EVS_SendEventWithAppID(CFE_SB_MSG_TOO_BIG_EID, CFE_EVS_EventType_ERROR, CFE_SB_Global.AppId,
"Send Err:Msg Too Big MsgId=0x%x,app=%s,size=%d,MaxSz=%d",
(unsigned int)CFE_SB_MsgIdToValue(*MsgIdPtr),
CFE_SB_GetAppTskName(TskId, FullName), (int)*SizePtr,
CFE_MISSION_SB_MAX_SB_MSG_SIZE);

/* clear the bit so the task may send this event again */
CFE_SB_FinishSendEvent(TskId, CFE_SB_MSG_TOO_BIG_EID_BIT);
}
break;

case CFE_SB_SEND_NO_SUBS_EID:
Expand Down
14 changes: 8 additions & 6 deletions modules/sb/fsw/src/cfe_sb_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@
#define CFE_SB_FILE_IO_ERR (-5)

/* bit map for stopping recursive event problem */
#define CFE_SB_SEND_NO_SUBS_EID_BIT 0
#define CFE_SB_GET_BUF_ERR_EID_BIT 1
#define CFE_SB_MSGID_LIM_ERR_EID_BIT 2
#define CFE_SB_Q_FULL_ERR_EID_BIT 3
#define CFE_SB_Q_WR_ERR_EID_BIT 4

#define CFE_SB_SEND_NO_SUBS_EID_BIT 0
#define CFE_SB_GET_BUF_ERR_EID_BIT 1
#define CFE_SB_MSGID_LIM_ERR_EID_BIT 2
#define CFE_SB_Q_FULL_ERR_EID_BIT 3
#define CFE_SB_Q_WR_ERR_EID_BIT 4
#define CFE_SB_SEND_BAD_ARG_EID_BIT 5
#define CFE_SB_SEND_INV_MSGID_EID_BIT 6
#define CFE_SB_MSG_TOO_BIG_EID_BIT 7
/*
** Type Definitions
*/
Expand Down

0 comments on commit efe8e74

Please sign in to comment.