diff --git a/include/fastdds/rtps/builtin/discovery/participant/PDP.h b/include/fastdds/rtps/builtin/discovery/participant/PDP.h index d30d5cbc0..b887b9a97 100644 --- a/include/fastdds/rtps/builtin/discovery/participant/PDP.h +++ b/include/fastdds/rtps/builtin/discovery/participant/PDP.h @@ -520,6 +520,10 @@ protected: //!Tell if object is enabled std::atomic enabled_ {false}; + std::mutex removal_mtx_; + std::condition_variable removal_cv_; + GUID_t processing_participant_guid_; + /** * Adds an entry to the collection of participant proxy information. * May use one of the entries present in the pool. diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index 1c2259f89..c1c0b6df5 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -1154,6 +1154,13 @@ bool PDP::remove_remote_participant( //Remove it from our vector or RTPSParticipantProxies: this->mp_mutex->lock(); + + if (processing_participant_guid_ == partGUID) + { + std::unique_lock lock (removal_mtx_); + removal_cv_.wait(lock); + } + for (ResourceLimitedVector::iterator pit = participant_proxies_.begin(); pit != participant_proxies_.end(); ++pit) { diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp index d37ff73ca..423f30e66 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPListener.cpp @@ -194,6 +194,7 @@ void PDPListener::process_alive_data( // Create a new one when not found old_data = parent_pdp_->createParticipantProxyData(new_data, writer_guid); + parent_pdp_->processing_participant_guid_ = old_data->m_guid; reader->getMutex().unlock(); lock.unlock(); @@ -211,6 +212,9 @@ void PDPListener::process_alive_data( // readers anyways. parent_pdp_->assignRemoteEndpoints(old_data); } + + parent_pdp_->processing_participant_guid_ = c_Guid_Unknown; + parent_pdp_->removal_cv_.notify_one(); } else {