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

View File

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