[CONPRO-1212] Removing invocation of lock_guard destructor. 49/174249/1
authorHarry <h.marappa@samsung.com>
Wed, 31 Jan 2018 09:22:21 +0000 (14:52 +0530)
committerAmit KS <amit.s12@samsung.com>
Thu, 29 Mar 2018 08:46:48 +0000 (14:16 +0530)
std::lock_guard follows RAII for std::mutex. Invoking
std::lock_guard<std::mutex>::~lock_guard() makes unlock
call twice on underlying mutex. As per the API documentation
calling unlock from thread which does not own lock results in
undefined behaviour.

https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/243
(cherry picked from commit fc681e089d3bbbbd16f90ad05d53208f9a1602d1)

Change-Id: Iaf21d318f5fa46daf2bcc17f0f07ffe9aa887b9d
Signed-off-by: Harry <h.marappa@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
service/resource-encapsulation/src/resourceCache/src/ResourceCacheManager.cpp

index 386e809..efe0cde 100644 (file)
@@ -134,7 +134,6 @@ namespace OIC
             if ((dataCacheIns == cacheIDmap.end() && observeIns == observeCacheIDmap.end())
                 || id == 0)
             {
-                lock.~lock_guard();
                 throw RCSInvalidParameterException {"[cancelResourceCache] CacheID is invaild"};
             }
 
@@ -148,7 +147,6 @@ namespace OIC
                 {
                     (observeIns->second).reset();
                     observeCacheIDmap.erase(id);
-                    lock.~lock_guard();
                     throw;
                 }
                 (observeIns->second).reset();