[IOT-1744] Fix for race-condition crash
authorGeorge Nash <george.nash@intel.com>
Fri, 20 Jan 2017 22:02:48 +0000 (14:02 -0800)
committerRick Bell <richard.s.bell@intel.com>
Mon, 23 Jan 2017 17:52:01 +0000 (17:52 +0000)
The resource-container was crashing when due to failure to
grab a lock when the resorce container was being stopped

This resulted in code trying to use the resource container
at the same time it was being unregistered resulting in
a segfault.

Note: RemoteResourceUnitTest.onCacheCBCalled test is still
failing due to a different issue. That test must be fixed
before IOT-1744 can be closed.

Bug: https://jira.iotivity.org/browse/IOT-1744
Change-Id: I2dc5061c1693cc81c4f54a65a5233790fb5336d2
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16637
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
service/resource-container/src/ResourceContainerImpl.cpp

index 889a34c..e1574a8 100644 (file)
@@ -124,6 +124,7 @@ namespace OIC
         {
             OIC_LOG(INFO, CONTAINER_TAG, "Stopping resource container.");
 
+            activationLock.lock();
             for (std::map< std::string, shared_ptr<BundleInfoInternal> >::iterator it = m_bundles.begin();
                  it != m_bundles.end(); ++it)
             {
@@ -148,6 +149,7 @@ namespace OIC
             {
                 delete m_config;
             }
+            activationLock.unlock();
         }
 
         void ResourceContainerImpl::activateBundle(shared_ptr<RCSBundleInfo> bundleInfo)