mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-11-04 12:59:07 +01:00
EventManager: Fix potential ABBA deadlock if callback contains locks
This commit is contained in:
committed by
Kyle Schwarz
parent
3932b54947
commit
fb241dc5cd
@@ -99,8 +99,12 @@ void EventManager::addEventInternal(APIEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::runCallbacks(APIEvent event) {
|
void EventManager::runCallbacks(APIEvent event) {
|
||||||
|
std::map<int, icsneo::EventCallback> tempCallbacks;
|
||||||
|
{
|
||||||
std::lock_guard<std::mutex> lk(callbacksMutex);
|
std::lock_guard<std::mutex> lk(callbacksMutex);
|
||||||
for(auto& i : callbacks)
|
tempCallbacks = callbacks;
|
||||||
|
}
|
||||||
|
for(auto& i : tempCallbacks)
|
||||||
i.second.callIfMatch(std::make_shared<APIEvent>(event));
|
i.second.callIfMatch(std::make_shared<APIEvent>(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user