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,9 +99,13 @@ void EventManager::addEventInternal(APIEvent event) {
|
||||
}
|
||||
|
||||
void EventManager::runCallbacks(APIEvent event) {
|
||||
std::lock_guard<std::mutex> lk(callbacksMutex);
|
||||
for(auto& i : callbacks)
|
||||
i.second.callIfMatch(std::make_shared<APIEvent>(event));
|
||||
std::map<int, icsneo::EventCallback> tempCallbacks;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(callbacksMutex);
|
||||
tempCallbacks = callbacks;
|
||||
}
|
||||
for(auto& i : tempCallbacks)
|
||||
i.second.callIfMatch(std::make_shared<APIEvent>(event));
|
||||
}
|
||||
|
||||
void EventManager::setEventLimit(size_t newLimit) {
|
||||
|
||||
Reference in New Issue
Block a user