Skip to content

If a message is subscribed, then unsubscribed, additional unsubscribes do not raise error events  #862

@johnphamngc

Description

@johnphamngc

Describe the bug
If a message is subscribed, then unsubscribed, additional unsubscribes do not raise error events

To Reproduce
Have SB subscribe to a message
Have SB unsubscribe to that message
Have SB unsubscribe again to that message

Expected behavior
Event message should be raised

Code snips

/* get index into routing table */
MsgKey = CFE_SB_ConvertMsgIdtoMsgKey(MsgId);
RouteIdx = CFE_SB_GetRoutingTblIdx(MsgKey);
/* if there are no subscriptions for this message id... */
if(!CFE_SB_IsValidRouteIdx(RouteIdx)){
char PipeName[OS_MAX_API_NAME] = {'\0'};
CFE_SB_UnlockSharedData(__func__,__LINE__);
CFE_SB_GetPipeName(PipeName, sizeof(PipeName), PipeId);
CFE_EVS_SendEventWithAppID(CFE_SB_UNSUB_NO_SUBS_EID,CFE_EVS_EventType_INFORMATION,CFE_SB.AppId,
"Unsubscribe Err:No subs for Msg 0x%x on %s,app %s",
(unsigned int)CFE_SB_MsgIdToValue(MsgId),
PipeName,CFE_SB_GetAppTskName(TskId,FullName));
return CFE_SUCCESS;
}/* end if */
/* At this point, there must be at least one destination. */
/* So the value of 'ListHeadPtr' will not be NULL by design */
RoutePtr = CFE_SB_GetRoutePtrFromIdx(RouteIdx);
/* search the list for a matching pipe id */
DestPtr = RoutePtr->ListHeadPtr;
do{
if(DestPtr->PipeId == PipeId){
/* match found, remove node from list */
CFE_SB_RemoveDest(RoutePtr,DestPtr);
/* return node to memory pool */
CFE_SB_PutDestinationBlk(DestPtr);
RoutePtr->Destinations--;
CFE_SB.StatTlmMsg.Payload.SubscriptionsInUse--;
MatchFound = true;
}/* end if */
DestPtr = DestPtr->Next;
}while((MatchFound == false)&&(DestPtr != NULL));
CFE_SB_UnlockSharedData(__func__,__LINE__);
CFE_EVS_SendEventWithAppID(CFE_SB_SUBSCRIPTION_REMOVED_EID,CFE_EVS_EventType_DEBUG,CFE_SB.AppId,
"Subscription Removed:Msg 0x%x on pipe %d,app %s",
(unsigned int)CFE_SB_MsgIdToValue(MsgId),
(int)PipeId,CFE_SB_GetAppTskName(TskId,FullName));
return CFE_SUCCESS;

If a message was previously subscribed to, and all pipes subscribing to it were subsequently unsubscribed, and an additional unsubscribe is issued, a valid routing index would still exist in the msgmap table, and thus an error event would not be raised.

System observed on:
N/A, discovered via code inspection

Additional context
N/A

Reporter Info
John N Pham, Northrop Grumman

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions