Fixed a bug in the cache module of RE
authorcoderhyme <jhyo.kim@samsung.com>
Mon, 14 Mar 2016 02:57:32 +0000 (19:57 -0700)
committerJungHo Kim <jhyo.kim@samsung.com>
Thu, 24 Mar 2016 11:34:12 +0000 (11:34 +0000)
If observation for a resource from a client is started, it should be canceled.
But there was a logic error that it isn't.

Change-Id: I2440c20999b7076bea5987ccbad3f0710269b3d9
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5807
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: JungYong KIM <jyong2.kim@samsung.com>
(cherry picked from commit 607ef0e262f85d164cb3b1edbcf2e5bf926a2930)
Reviewed-on: https://gerrit.iotivity.org/gerrit/6259

service/resource-encapsulation/src/resourceCache/src/DataCache.cpp

index 86a1428..51b3536 100644 (file)
@@ -42,10 +42,10 @@ namespace OIC
                 const HeaderOptions &_hos, const ResponseStatement &_rep,
                 int _result, unsigned int _seq, std::weak_ptr<DataCache> rpPtr)
             {
-                std::shared_ptr<DataCache> Ptr = rpPtr.lock();
-                if (Ptr)
+                std::shared_ptr<DataCache> ptr = rpPtr.lock();
+                if (ptr)
                 {
-                    Ptr->onObserve(_hos, _rep, _result, _seq);
+                    ptr->onObserve(_hos, _rep, _result, _seq);
                 }
             }
 
@@ -100,7 +100,7 @@ namespace OIC
                 subscriberList.release();
             }
 
-            if (mode == CACHE_MODE::OBSERVE)
+            if (sResource->isObservable())
             {
                 try
                 {
@@ -184,7 +184,7 @@ namespace OIC
 
         const PrimitiveResourcePtr DataCache::getPrimitiveResource() const
         {
-            return (sResource != nullptr) ? sResource : nullptr;
+            return sResource;
         }
 
         const RCSResourceAttributes DataCache::getCachedData() const