From b9f2f7457dc36cbcdd530fd17e56bc974afc405f Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Wed, 20 Nov 2019 22:15:00 -0800 Subject: [PATCH] Fix deadlock between PDP and StatefulReader (#871) * Fix deadlock between PDP and StatefulReader This releases the PDP mutex before calling a function that may try to acquire the mutex on a StatefulReader. Signed-off-by: Shane Loretz Signed-off-by: Shane Loretz * Removing unnecessary lock(). --- src/cpp/rtps/builtin/discovery/participant/PDP.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 2de23678724..4f38de78a1b 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -996,7 +996,7 @@ CDRMessage_t PDP::get_participant_proxy_data_serialized(Endianness_t endian) void PDP::check_remote_participant_liveliness( ParticipantProxyData* remote_participant) { - std::lock_guard guard(*this->mp_mutex); + std::unique_lock guard(*this->mp_mutex); if(GUID_t::unknown() != remote_participant->m_guid) { @@ -1007,6 +1007,7 @@ void PDP::check_remote_participant_liveliness( std::chrono::microseconds(TimeConv::Duration_t2MicroSecondsInt64(remote_participant->m_leaseDuration)); if (now > real_lease_tm) { + guard.unlock(); remove_remote_participant(remote_participant->m_guid, ParticipantDiscoveryInfo::DROPPED_PARTICIPANT); return; }