diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 83c01a9098f..2e6970bb317 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -1217,9 +1217,9 @@ bool StatefulWriter::matched_reader_remove( const GUID_t& reader_guid) { ReaderProxy* rproxy = nullptr; + std::lock_guard lock(mp_mutex); { - std::lock_guard lock(mp_mutex); std::lock_guard guard_locator_selector_general(locator_selector_general_); std::lock_guard guard_locator_selector_async(locator_selector_async_);