@@ -1141,7 +1141,8 @@ int32 CFE_SB_SendPipeInfo(const char *Filename)
1141
1141
uint32 EntryCount = 0 ;
1142
1142
CFE_FS_Header_t FileHdr ;
1143
1143
CFE_SB_PipeD_t * PipeDscPtr ;
1144
- CFE_SB_PipeD_t entry ; /* NOTE: Should be separate/dedicated type */
1144
+ CFE_SB_PipeInfoEntry_t FileEntry ;
1145
+ osal_id_t SysQueueId ;
1145
1146
1146
1147
Status = OS_OpenCreate (& fd , Filename , OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE , OS_WRITE_ONLY );
1147
1148
@@ -1172,14 +1173,38 @@ int32 CFE_SB_SendPipeInfo(const char *Filename)
1172
1173
{
1173
1174
if (CFE_SB_PipeDescIsUsed (PipeDscPtr ))
1174
1175
{
1175
- memcpy (& entry , PipeDscPtr , sizeof (CFE_SB_PipeD_t ));
1176
+ /*
1177
+ * Ensure any old data in the struct has been cleared
1178
+ */
1179
+ memset (& FileEntry , 0 , sizeof (FileEntry ));
1180
+
1181
+ /*
1182
+ * Take a "snapshot" of the PipeDsc state while locked
1183
+ */
1184
+ FileEntry .PipeId = CFE_SB_PipeDescGetID (PipeDscPtr );
1185
+ FileEntry .AppId = PipeDscPtr -> AppId ;
1186
+ FileEntry .MaxQueueDepth = PipeDscPtr -> QueueDepth ;
1187
+ FileEntry .CurrentQueueDepth = PipeDscPtr -> CurrentDepth ;
1188
+ FileEntry .PeakQueueDepth = PipeDscPtr -> PeakDepth ;
1189
+ FileEntry .SendErrors = PipeDscPtr -> SendErrors ;
1190
+ FileEntry .Opts = PipeDscPtr -> Opts ;
1191
+ SysQueueId = PipeDscPtr -> SysQueueId ;
1176
1192
1177
1193
CFE_SB_UnlockSharedData (__FILE__ ,__LINE__ );
1178
1194
1179
- Status = OS_write (fd , & entry , sizeof (CFE_SB_PipeD_t ));
1180
- if (Status != sizeof (CFE_SB_PipeD_t ))
1195
+ /*
1196
+ * Gather data from other subsystems while unlocked.
1197
+ * This might fail if the pipe is deleted simultaneously while this runs, but in
1198
+ * the unlikely event that happens, the name data will simply be blank as the ID(s)
1199
+ * will not validate.
1200
+ */
1201
+ OS_GetResourceName (SysQueueId , FileEntry .PipeName , sizeof (FileEntry .PipeName ));
1202
+ CFE_ES_GetAppName (FileEntry .AppName , FileEntry .AppId , sizeof (FileEntry .AppName ));
1203
+
1204
+ Status = OS_write (fd , & FileEntry , sizeof (FileEntry ));
1205
+ if (Status != sizeof (FileEntry ))
1181
1206
{
1182
- CFE_SB_FileWriteByteCntErr (Filename ,sizeof (CFE_SB_PipeD_t ),Status );
1207
+ CFE_SB_FileWriteByteCntErr (Filename ,sizeof (FileEntry ),Status );
1183
1208
OS_close (fd );
1184
1209
return CFE_SB_FILE_IO_ERR ;
1185
1210
}/* end if */
0 commit comments