Shm::Monitor: add nullptr check for segment info

This commit is contained in:
Alexey Rybalchenko 2022-05-28 12:57:30 +02:00
parent 69faa63c5b
commit d3ae8df55f

View File

@ -660,6 +660,8 @@ void Monitor::ResetContent(const ShmId& shmIdT, bool verbose /* = true */)
managed_shared_memory managementSegment(open_only, managementSegmentName.c_str());
Uint16SegmentInfoHashMap* segmentInfos = managementSegment.find<Uint16SegmentInfoHashMap>(unique_instance).first;
if (segmentInfos) {
cout << "Found info for " << segmentInfos->size() << " managed segments" << endl;
for (const auto& s : *segmentInfos) {
if (verbose) {
cout << "Resetting content of segment '" << "fmq_" << shmId << "_m_" << s.first << "'..." << endl;
@ -682,6 +684,9 @@ void Monitor::ResetContent(const ShmId& shmIdT, bool verbose /* = true */)
}
}
}
} else {
cout << "Found management segment, but cannot locate segment info, something went wrong..." << endl;
}
Uint16RegionInfoHashMap* shmRegions = managementSegment.find<Uint16RegionInfoHashMap>(bipc::unique_instance).first;
if (shmRegions) {