shm: Make sure all region events are fired

This commit is contained in:
Alexey Rybalchenko 2021-02-26 11:39:24 +01:00
parent cb4335e59f
commit 9b48b31a75
2 changed files with 9 additions and 9 deletions

View File

@ -415,10 +415,10 @@ class Manager
while (fRegionEventsSubscriptionActive) {
auto infos = GetRegionInfoUnsafe();
for (const auto& i : infos) {
auto el = fObservedRegionEvents.find(i.id);
auto el = fObservedRegionEvents.find({i.id, i.managed});
if (el == fObservedRegionEvents.end()) {
fRegionEventCallback(i);
fObservedRegionEvents.emplace(i.id, i.event);
fObservedRegionEvents.emplace(std::make_pair(i.id, i.managed), i.event);
} else {
if (el->second == RegionEvent::created && i.event == RegionEvent::destroyed) {
fRegionEventCallback(i);
@ -617,7 +617,7 @@ class Manager
std::thread fRegionEventThread;
bool fRegionEventsSubscriptionActive;
std::function<void(fair::mq::RegionInfo)> fRegionEventCallback;
std::unordered_map<uint16_t, RegionEvent> fObservedRegionEvents;
std::map<std::pair<uint16_t, bool>, RegionEvent> fObservedRegionEvents;
DeviceCounter* fDeviceCounter;
Uint16SegmentInfoHashMap* fShmSegments;

View File

@ -50,12 +50,12 @@ void RegionEventSubscriptions(const string& transport)
ASSERT_EQ(factory->SubscribedToRegionEvents(), false);
factory->SubscribeToRegionEvents([&](FairMQRegionInfo info) {
LOG(warn) << ">>>" << info.event;
LOG(warn) << "managed: " << info.managed;
LOG(warn) << "id: " << info.id;
LOG(warn) << "ptr: " << info.ptr;
LOG(warn) << "size: " << info.size;
LOG(warn) << "flags: " << info.flags;
LOG(info) << ">>> " << info.event << ": "
<< (info.managed ? "managed" : "unmanaged")
<< ", id: " << info.id
<< ", ptr: " << info.ptr
<< ", size: " << info.size
<< ", flags: " << info.flags;
if (info.event == FairMQRegionEvent::created) {
if (info.id == id1) {
ASSERT_EQ(info.size, size1);