From 293b2060b84917cf1d5c66040f05ed0825b6aa9a Mon Sep 17 00:00:00 2001 From: Kevin Matz Date: Sat, 10 Dec 2022 13:34:45 -0500 Subject: [PATCH] don't hold the control lock when doing callbacks --- protocol/esta/dmx/universe.cpp | 6 +----- protocol/esta/sacn/arbitratinguniverse.cpp | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/protocol/esta/dmx/universe.cpp b/protocol/esta/dmx/universe.cpp index 5963d6a..683caa2 100644 --- a/protocol/esta/dmx/universe.cpp +++ b/protocol/esta/dmx/universe.cpp @@ -295,7 +295,6 @@ void Universe::rx_timeout_(bool add_now) */ void Universe::do_callbacks_(std::vector>> & callbacks) { - std::shared_lock lk_ctl(mtx_control); for (auto it = callbacks.cbegin(); it != callbacks.cend();) { if (auto sp = it->lock()) @@ -305,11 +304,8 @@ void Universe::do_callbacks_(std::vector ArbitratingUniverse::onSourceListChange(std::functionlock()) @@ -202,12 +201,8 @@ void ArbitratingUniverse::doListChangeCallbacks() } else { // or remove the callback - - lk_ctl.unlock(); // release the shared lock - mtx_control.lock(); // take a unique lock + std::unique_lock lk_ctl(mtx_control); it = cb_sourceListChange.erase(it); - mtx_control.unlock(); // release the unique lock - lk_ctl.lock(); // retake the shared lock } } }