As InProcClientWrapper class creates separate thread for every
obseve callback, There is a chance that more than one thread enter
ObserveCache object and trying to modify m_attributes. More over
same m_attributes is being passed out or RE layer by const reference,
so application is using same member object m_attributes. Mutex allows
only one thread to modify m_attributes.
https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/276
(cherry picked from commit
c87d0d4b14d22349c3563e7cd316d323d068e2ab)
Change-Id: I54c80a6ea9751b8d9f78720121bee949d336ce4f
Signed-off-by: Harry <h.marappa@samsung.com>
Signed-off-by: Amit KS <amit.s12@samsung.com>
RCSResourceAttributes m_attributes;
CACHE_STATE m_state;
+ std::mutex m_cbMutex;
DataCacheCB m_reportCB;
std::atomic<bool> m_isStart;
void ObserveCache::onObserve(const HeaderOptions &,
const ResponseStatement & rep, int _result, unsigned int)
{
+ std::lock_guard<std::mutex> lock(m_cbMutex);
m_state = CACHE_STATE::READY;
if (m_attributes == rep.getAttributes() &&
convertOCResultToSuccess((OCStackResult)_result))
{
- return ;
+ return;
}
if (m_reportCB)