Skip to content

Commit

Permalink
Automatically unmatch remote participants on participant deletion (#4849
Browse files Browse the repository at this point in the history
) (#4865)

* Automatically unmatch remote participants on participant deletion (#4849)

* Refs #21055. Add regresion test.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. Remove `this->` on PDP.cpp

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. Change nullptr comparisons on PDP.cpp

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. Change nullptr comparisons on BuiltinProtocols.cpp

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. Split `PDP::remove_remote_participant` in two methods.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. Call new `PDP::disable` method when deleting `BuiltinProtocols`.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. `PDP::disable` method automatically unmatches remote participants.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #21055. Use `std::lock_guard` where possible.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20995. Apply suggestion.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

* Refs #20995. Fix test build.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>

---------

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
(cherry picked from commit 689dd3f)

# Conflicts:
#	include/fastdds/rtps/builtin/discovery/participant/PDP.h
#	src/cpp/rtps/builtin/discovery/participant/PDP.cpp
#	test/blackbox/common/DDSBlackboxTestsBasic.cpp

* Refs #21244: Fix conflicts

Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>

* Refs #21055: Fix build issue

Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>

---------

Signed-off-by: JesusPoderoso <jesuspoderoso@eprosima.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
Co-authored-by: JesusPoderoso <jesuspoderoso@eprosima.com>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 01ab5cd commit 36fefdb
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 107 deletions.
20 changes: 20 additions & 0 deletions include/fastdds/rtps/builtin/discovery/participant/PDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class PDP
*/
bool enable();

/**
* @brief Disable the Participant Discovery Protocol
*/
void disable();

virtual bool init(
RTPSParticipantImpl* part) = 0;

Expand Down Expand Up @@ -545,6 +550,21 @@ class PDP
*/
void set_initial_announcement_interval();

/**
* Performs all the necessary actions after removing a ParticipantProxyData from the
* participant_proxies_ collection.
*
* @param pdata ParticipantProxyData that was removed.
* @param partGUID GUID of the removed participant.
* @param reason Reason why the participant was removed.
* @param listener Listener to be notified of the unmatches / removal.
*/
void actions_on_remote_participant_removed(
ParticipantProxyData* pdata,
const GUID_t& partGUID,
ParticipantDiscoveryInfo::DISCOVERY_STATUS reason,
RTPSParticipantListener* listener);

};


Expand Down
25 changes: 14 additions & 11 deletions src/cpp/rtps/builtin/BuiltinProtocols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ BuiltinProtocols::BuiltinProtocols()
BuiltinProtocols::~BuiltinProtocols()
{
// Send participant is disposed
if (mp_PDP != nullptr)
if (nullptr != mp_PDP)
{
// Send participant is disposed
mp_PDP->announceParticipantState(true, true);
// Consider all discovered participants as disposed
mp_PDP->disable();
}

// TODO Auto-generated destructor stub
Expand Down Expand Up @@ -194,7 +197,7 @@ bool BuiltinProtocols::addLocalWriter(
{
bool ok = true;

if (mp_PDP != nullptr)
if (nullptr != mp_PDP)
{
ok = mp_PDP->getEDP()->newLocalWriterProxyData(w, topicAtt, wqos);

Expand All @@ -209,7 +212,7 @@ bool BuiltinProtocols::addLocalWriter(
logWarning(RTPS_EDP, "EDP is not used in this Participant, register a Writer is impossible");
}

if (mp_WLP != nullptr)
if (nullptr != mp_WLP)
{
ok &= mp_WLP->add_local_writer(w, wqos);
}
Expand All @@ -228,7 +231,7 @@ bool BuiltinProtocols::addLocalReader(
{
bool ok = true;

if (mp_PDP != nullptr)
if (nullptr != mp_PDP)
{
ok = mp_PDP->getEDP()->newLocalReaderProxyData(R, topicAtt, rqos, content_filter);

Expand All @@ -243,7 +246,7 @@ bool BuiltinProtocols::addLocalReader(
logWarning(RTPS_EDP, "EDP is not used in this Participant, register a Reader is impossible");
}

if (mp_WLP != nullptr)
if (nullptr != mp_WLP)
{
ok &= mp_WLP->add_local_reader(R, rqos);
}
Expand All @@ -257,7 +260,7 @@ bool BuiltinProtocols::updateLocalWriter(
const WriterQos& wqos)
{
bool ok = false;
if (mp_PDP != nullptr && mp_PDP->getEDP() != nullptr)
if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP()))
{
ok = mp_PDP->getEDP()->updatedLocalWriter(W, topicAtt, wqos);
}
Expand All @@ -271,7 +274,7 @@ bool BuiltinProtocols::updateLocalReader(
const fastdds::rtps::ContentFilterProperty* content_filter)
{
bool ok = false;
if (mp_PDP != nullptr && mp_PDP->getEDP() != nullptr)
if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP()))
{
ok = mp_PDP->getEDP()->updatedLocalReader(R, topicAtt, rqos, content_filter);
}
Expand All @@ -282,11 +285,11 @@ bool BuiltinProtocols::removeLocalWriter(
RTPSWriter* W)
{
bool ok = false;
if (mp_WLP != nullptr)
if (nullptr != mp_WLP)
{
ok |= mp_WLP->remove_local_writer(W);
}
if (mp_PDP != nullptr && mp_PDP->getEDP() != nullptr)
if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP()))
{
ok |= mp_PDP->getEDP()->removeLocalWriter(W);
}
Expand All @@ -297,11 +300,11 @@ bool BuiltinProtocols::removeLocalReader(
RTPSReader* R)
{
bool ok = false;
if (mp_WLP != nullptr)
if (nullptr != mp_WLP)
{
ok |= mp_WLP->remove_local_reader(R);
}
if (mp_PDP != nullptr && mp_PDP->getEDP() != nullptr)
if ((nullptr != mp_PDP) && (nullptr != mp_PDP->getEDP()))
{
ok |= mp_PDP->getEDP()->removeLocalReader(R);
}
Expand Down
Loading

0 comments on commit 36fefdb

Please sign in to comment.