Try to fix the potential data race in InformatonProviderImpl
* Fix potential data race in InformatonProviderImpl
* Won't lock the local_callbacks entire scope
Move the mutex lock into the desired block, only protect `m_` properties.
@@ -73,13 +73,14 @@ namespace PAL_NS_BEGIN {
// be deleted. The current design is that IPropertyChangedCallback is
// not refcount'ed. Should we refcount it?
- if (m_registeredCount > 0)
- {
std::vector<IPropertyChangedCallback*> local_callbacks;
{
std::lock_guard<std::mutex> lock(m_lock);
+ if (m_registeredCount > 0)
+ {
local_callbacks.insert(local_callbacks.end(), m_callbacks.begin(), m_callbacks.end());
}
+ }
size_t count = local_callbacks.size();
for (size_t index = 0; index < count; ++index)
@@ -91,7 +92,6 @@ namespace PAL_NS_BEGIN {
}
}
}
- }
catch (...)
{
