X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=service%2Fresource-encapsulation%2Fsrc%2FresourceCache%2Fsrc%2FDataCache.cpp;h=23ffd309e728f5fd8b0a6504383cd1a94ca6dff2;hb=refs%2Ftags%2Faccepted%2Ftizen%2Funified%2F20171010.063815;hp=51b3536a5906e44347661c834955530363d13fe7;hpb=dbdccd21aa801bdf33b6277f17387b2dda7eb50a;p=platform%2Fupstream%2Fiotivity.git diff --git a/service/resource-encapsulation/src/resourceCache/src/DataCache.cpp b/service/resource-encapsulation/src/resourceCache/src/DataCache.cpp index 51b3536..23ffd30 100644 --- a/service/resource-encapsulation/src/resourceCache/src/DataCache.cpp +++ b/service/resource-encapsulation/src/resourceCache/src/DataCache.cpp @@ -31,6 +31,8 @@ #include "RCSResourceAttributes.h" #include "ExpiryTimer.h" +#include "ocrandom.h" + namespace OIC { namespace Service @@ -206,14 +208,7 @@ namespace OIC const ResponseStatement &_rep, int _result, unsigned int _seq) { - if (_result != OC_STACK_OK || _rep.getAttributes().empty() || lastSequenceNum > _seq) - { - return; - } - else - { - lastSequenceNum = _seq; - } + lastSequenceNum = _seq; if (state != CACHE_STATE::READY) { @@ -229,7 +224,7 @@ namespace OIC networkTimer.cancel(networkTimeOutHandle); networkTimeOutHandle = networkTimer.post(CACHE_DEFAULT_EXPIRED_MILLITIME, pTimerCB); - notifyObservers(_rep.getAttributes()); + notifyObservers(_rep.getAttributes(), _result); } void DataCache::onGet(const HeaderOptions & /*_hos*/, @@ -255,10 +250,10 @@ namespace OIC pollingHandle = pollingTimer.post(CACHE_DEFAULT_REPORT_MILLITIME, pPollingCB); } - notifyObservers(_rep.getAttributes()); + notifyObservers(_rep.getAttributes(), _result); } - void DataCache::notifyObservers(const RCSResourceAttributes Att) + void DataCache::notifyObservers(const RCSResourceAttributes Att, int eCode) { { std::lock_guard lock(att_mutex); @@ -274,7 +269,7 @@ namespace OIC { if (i.second.first.rf == REPORT_FREQUENCY::UPTODATE) { - i.second.second(this->sResource, Att); + i.second.second(this->sResource, Att, eCode); } } } @@ -314,17 +309,15 @@ namespace OIC CacheID DataCache::generateCacheID() { CacheID retID = 0; - srand(time(NULL)); - while (1) { if (findSubscriber(retID).first == 0 && retID != 0) { break; } - retID = rand(); - } + retID = OCGetRandom(); + } return retID; }