summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Stoffel <wilstoff@gmail.com>2021-03-10 05:38:52 -0600
committerGitHub <noreply@github.com>2021-03-10 12:38:52 +0100
commit3c4b87e71e554de4ce056b721f9043b5e828b36f (patch)
treeb6b998121035f0f6d9c3bc3f363abf73eee1f2dd
parentAdd class cycle detection during unmarshaling (diff)
downloadice-3c4b87e71e554de4ce056b721f9043b5e828b36f.tar.bz2
ice-3c4b87e71e554de4ce056b721f9043b5e828b36f.tar.xz
ice-3c4b87e71e554de4ce056b721f9043b5e828b36f.zip
Lock subscription mutex around optional trace logs (#1260)
- The _subscribers vector was utilized in the trace function without obtaining a lock. This vector could change size and lead to a segfault. Co-authored-by: Bill Stoffel <bstoffel@belvederetrading.com>
-rw-r--r--cpp/src/IceStorm/TopicI.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp
index badd3ec8435..0b1cf1f0b31 100644
--- a/cpp/src/IceStorm/TopicI.cpp
+++ b/cpp/src/IceStorm/TopicI.cpp
@@ -527,6 +527,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);
@@ -549,8 +551,6 @@ TopicImpl::subscribeAndGetPublisher(const QoS& qos, const Ice::ObjectPrx& obj)
}
}
- IceUtil::Mutex::Lock sync(_subscribersMutex);
-
SubscriberRecord record;
record.id = id;
record.obj = obj;
@@ -621,6 +621,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);
@@ -633,7 +634,6 @@ TopicImpl::unsubscribe(const Ice::ObjectPrx& subscriber)
}
}
- IceUtil::Mutex::Lock sync(_subscribersMutex);
Ice::IdentitySeq ids;
ids.push_back(id);
removeSubscribers(ids);