Skip to content

Commit 6111470

Browse files
committed
Fix @2862, correct app context in events
Applies the same fix which was done for the table dump command to all other operations that use the same basic event-sending mechanism. When the caller name is blank, this means it was invoked by a table services command. This changes the event to indicate it was a command rather than the "app=" empty string.
1 parent 546a002 commit 6111470

7 files changed

Lines changed: 47 additions & 25 deletions

File tree

‎modules/tbl/fsw/src/cfe_tbl_dump.c‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ bool CFE_TBL_SendDumpEventHelper(const CFE_TBL_TxnEvent_t *Event, CFE_TBL_TxnEve
420420
const CFE_TBL_DumpContext_t *DumpCtxt;
421421
uint16 EventType;
422422
char EventString[CFE_MISSION_EVS_MAX_MESSAGE_LENGTH];
423-
char CallerString[CFE_MISSION_MAX_API_LEN + 8];
424423

425424
DumpCtxt = Ctxt->OperationDataPtr;
426425

@@ -487,24 +486,13 @@ bool CFE_TBL_SendDumpEventHelper(const CFE_TBL_TxnEvent_t *Event, CFE_TBL_TxnEve
487486
return false;
488487
}
489488

490-
if (Ctxt->CallerName[0] == 0)
491-
{
492-
/* Empty name indicates it was initiated via ground command */
493-
snprintf(CallerString, sizeof(CallerString), "command");
494-
}
495-
else
496-
{
497-
/* non-Empty name means it was initiated by another app via API */
498-
snprintf(CallerString, sizeof(CallerString), "app=%s", Ctxt->CallerName);
499-
}
500-
501489
/* Finally send the actual event by appending all the info we have */
502490
CFE_EVS_SendEventWithAppID(Event->EventId,
503491
EventType,
504492
CFE_TBL_Global.TableTaskAppId,
505-
"%s by %s,table=%s,file=%s:%s",
493+
"%s%s,table=%s,file=%s:%s",
506494
Ctxt->Operation,
507-
CallerString,
495+
Ctxt->CallerIdent,
508496
DumpCtxt->RequestedTableName,
509497
DumpCtxt->FileName,
510498
EventString);

‎modules/tbl/fsw/src/cfe_tbl_load.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,9 @@ bool CFE_TBL_SendLoadBasicEventHelper(const CFE_TBL_TxnEvent_t *Event, CFE_TBL_T
426426
CFE_EVS_SendEventWithAppID(Event->EventId,
427427
EventType,
428428
CFE_TBL_Global.TableTaskAppId,
429-
"%s,app=%s,tbl=%s:%s",
429+
"%s%s,tbl=%s:%s",
430430
Ctxt->Operation,
431-
Ctxt->CallerName,
431+
Ctxt->CallerIdent,
432432
Ctxt->TableName,
433433
EventString);
434434

@@ -602,9 +602,9 @@ bool CFE_TBL_SendLoadFileEventHelper(const CFE_TBL_TxnEvent_t *Event, CFE_TBL_Tx
602602
CFE_EVS_SendEventWithAppID(Event->EventId,
603603
EventType,
604604
CFE_TBL_Global.TableTaskAppId,
605-
"%s,app=%s,file=%s,tbl=%s:%s",
605+
"%s%s,file=%s,tbl=%s:%s",
606606
Ctxt->Operation,
607-
Ctxt->CallerName,
607+
Ctxt->CallerIdent,
608608
LoadFileCtxt->LoadFilename,
609609
Ctxt->TableName,
610610
EventString);

‎modules/tbl/fsw/src/cfe_tbl_loadbuff.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,9 @@ bool CFE_TBL_SendActivationEventHelper(const CFE_TBL_TxnEvent_t *Event, CFE_TBL_
593593
CFE_EVS_SendEventWithAppID(Event->EventId,
594594
EventType,
595595
CFE_TBL_Global.TableTaskAppId,
596-
"%s,app=%s,tbl=%s:%s",
596+
"%s%s,tbl=%s:%s",
597597
Ctxt->Operation,
598-
Ctxt->CallerName,
598+
Ctxt->CallerIdent,
599599
Ctxt->TableName,
600600
EventString);
601601

‎modules/tbl/fsw/src/cfe_tbl_transaction.c‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,32 @@ void CFE_TBL_SendTransactionEvents(CFE_TBL_TxnState_t *Txn,
406406
const void *OperationData)
407407
{
408408
CFE_TBL_TxnEventContext_t Ctxt;
409+
const char *CallerName;
409410

410411
memset(&Ctxt, 0, sizeof(Ctxt));
411412

412413
Ctxt.Operation = Operation;
413414
Ctxt.OperationDataPtr = OperationData;
414-
Ctxt.CallerName = CFE_TBL_TxnAppNameCaller(Txn);
415-
Ctxt.RegRecPtr = CFE_TBL_TxnRegRec(Txn);
415+
416+
/* If called by table services itself, leave the CallerIdent blank.
417+
* Otherwise make it a string snippet to append to the event */
418+
if (CFE_RESOURCEID_TEST_DEFINED(Txn->AppId)
419+
&& !CFE_RESOURCEID_TEST_EQUAL(Txn->AppId, CFE_TBL_Global.TableTaskAppId))
420+
{
421+
CallerName = CFE_TBL_TxnAppNameCaller(Txn);
422+
if (CallerName[0] == 0)
423+
{
424+
/* Empty name indicates it was initiated via ground command */
425+
snprintf(Ctxt.CallerIdent, sizeof(Ctxt.CallerIdent), ",appid=%lx", CFE_RESOURCEID_TO_ULONG(Txn->AppId));
426+
}
427+
else
428+
{
429+
/* non-Empty name means it was initiated by another app via API */
430+
snprintf(Ctxt.CallerIdent, sizeof(Ctxt.CallerIdent), ",app=%s", CallerName);
431+
}
432+
}
433+
434+
Ctxt.RegRecPtr = CFE_TBL_TxnRegRec(Txn);
416435

417436
if (Ctxt.RegRecPtr != NULL)
418437
{

‎modules/tbl/fsw/src/cfe_tbl_transaction.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ typedef struct CFE_TBL_TxnEventContext_t
145145
const void *OperationDataPtr;
146146

147147
const char *TableName;
148-
const char *CallerName;
148+
149+
/* a string which indicates the calling context of the operation. For
150+
* operations done via API call this looks like "app=<app-name>" */
151+
char CallerIdent[CFE_MISSION_MAX_API_LEN + 8];
149152

150153
const CFE_TBL_RegistryRec_t *RegRecPtr;
151154

‎modules/tbl/fsw/src/cfe_tbl_valresult.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ bool CFE_TBL_SendValidationEventHelper(const CFE_TBL_TxnEvent_t *Event, CFE_TBL_
259259
CFE_EVS_SendEventWithAppID(Event->EventId,
260260
EventType,
261261
CFE_TBL_Global.TableTaskAppId,
262-
"%s,app=%s,tbl=%s:%s",
262+
"%s%s,tbl=%s:%s",
263263
Ctxt->Operation,
264-
Ctxt->CallerName,
264+
Ctxt->CallerIdent,
265265
Ctxt->TableName,
266266
EventString);
267267

‎modules/tbl/ut-coverage/tbl_UT.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,6 +2235,18 @@ void Test_CFE_TBL_TableDumpCommon(void)
22352235
CFE_TBL_TxnAddEvent(&Txn, -1, -1, -1);
22362236
CFE_TBL_SendTableDumpEvents(&Txn, NULL, NULL);
22372237
UtAssert_STUB_COUNT(CFE_EVS_SendEventWithAppID, 0); /* nothing should have been sent */
2238+
2239+
memset(&Txn, 0, sizeof(Txn));
2240+
CFE_TBL_TxnAddEvent(&Txn, -1, -1, -1);
2241+
Txn.AppId = CFE_TBL_Global.TableTaskAppId;
2242+
CFE_TBL_SendTableDumpEvents(&Txn, NULL, NULL);
2243+
UtAssert_STUB_COUNT(CFE_EVS_SendEventWithAppID, 0); /* nothing should have been sent */
2244+
2245+
memset(&Txn, 0, sizeof(Txn));
2246+
CFE_TBL_TxnAddEvent(&Txn, -1, -1, -1);
2247+
Txn.AppId = CFE_ES_APPID_C(CFE_ResourceId_FromInteger(1));
2248+
CFE_TBL_SendTableDumpEvents(&Txn, NULL, NULL);
2249+
UtAssert_STUB_COUNT(CFE_EVS_SendEventWithAppID, 0); /* nothing should have been sent */
22382250
}
22392251

22402252
/*

0 commit comments

Comments
 (0)