Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock subscription mutex around optional trace logs #1259

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cpp/src/IceStorm/TopicI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@ TopicImpl::subscribeAndGetPublisher(const QoS& qos, const Ice::ObjectPrx& obj)
Ice::Identity id = obj->ice_getIdentity();

TraceLevelsPtr traceLevels = _instance->traceLevels();

IceUtil::Mutex::Lock sync(_subscribersMutex);
if(traceLevels->topic > 0)
{
Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
Expand All @@ -525,8 +527,6 @@ TopicImpl::subscribeAndGetPublisher(const QoS& qos, const Ice::ObjectPrx& obj)
}
}

IceUtil::Mutex::Lock sync(_subscribersMutex);

SubscriberRecord record;
record.id = id;
record.obj = obj;
Expand Down Expand Up @@ -587,6 +587,7 @@ TopicImpl::unsubscribe(const Ice::ObjectPrx& subscriber)

Ice::Identity id = subscriber->ice_getIdentity();

IceUtil::Mutex::Lock sync(_subscribersMutex);
if(traceLevels->topic > 0)
{
Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
Expand All @@ -598,8 +599,6 @@ TopicImpl::unsubscribe(const Ice::ObjectPrx& subscriber)
trace(out, _instance, _subscribers);
}
}

IceUtil::Mutex::Lock sync(_subscribersMutex);
Ice::IdentitySeq ids;
ids.push_back(id);
removeSubscribers(ids);
Expand Down