Skip to content

Commit

Permalink
Refs #21120. Fix discovery server tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Jun 6, 2024
1 parent 7901acd commit 258078d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/cpp/rtps/builtin/discovery/participant/PDPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <rtps/builtin/discovery/participant/timedevent/DSClientEvent.h>
#include <rtps/builtin/liveliness/WLP.hpp>
#include <rtps/participant/RTPSParticipantImpl.h>
#include <rtps/reader/BaseReader.hpp>
#include <rtps/reader/StatefulReader.hpp>
#include <rtps/writer/StatefulWriter.hpp>
#include <utils/shared_mutex.hpp>
Expand Down Expand Up @@ -348,7 +349,6 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(
ratt.endpoint.reliabilityKind = RELIABLE;
ratt.times.heartbeatResponseDelay = pdp_heartbeat_response_delay;
#if HAVE_SECURITY
ratt.accept_messages_from_unkown_writers = !is_discovery_protected && mp_RTPSParticipant->is_secure();
if (is_discovery_protected)
{
ratt.endpoint.security_attributes().is_submessage_protected = true;
Expand Down Expand Up @@ -460,6 +460,10 @@ bool PDPClient::create_ds_pdp_reliable_endpoints(
match_pdp_writer_nts_(it);
match_pdp_reader_nts_(it);
}
else if (!is_discovery_protected)
{
BaseReader::downcast(endpoints.reader.reader_)->allow_unknown_writers();
}
#else
if (!is_discovery_protected)
{
Expand Down
6 changes: 4 additions & 2 deletions src/cpp/rtps/builtin/discovery/participant/PDPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <rtps/builtin/discovery/participant/timedevent/DServerEvent.hpp>
#include <rtps/builtin/liveliness/WLP.hpp>
#include <rtps/participant/RTPSParticipantImpl.h>
#include <rtps/reader/BaseReader.hpp>
#include <rtps/reader/StatefulReader.hpp>
#include <rtps/writer/StatefulWriter.hpp>
#include <utils/TimeConversion.hpp>
Expand Down Expand Up @@ -401,13 +402,14 @@ bool PDPServer::create_ds_pdp_reliable_endpoints(
#else
EntityId_t reader_entity = c_EntityId_SPDPReader;
#endif // if HAVE_SECURITY
// Enable unknown clients to reach this reader
ratt.accept_messages_from_unkown_writers = true;
if (mp_RTPSParticipant->createReader(&reader, ratt, endpoints.reader.history_.get(),
endpoints.reader.listener_.get(), reader_entity, true, false))
{
endpoints.reader.reader_ = dynamic_cast<fastrtps::rtps::StatefulReader*>(reader);

// Enable unknown clients to reach this reader
BaseReader::downcast(endpoints.reader.reader_)->allow_unknown_writers();

#if HAVE_SECURITY
mp_RTPSParticipant->set_endpoint_rtps_protection_supports(reader, false);
#endif // if HAVE_SECURITY
Expand Down
5 changes: 5 additions & 0 deletions src/cpp/rtps/reader/BaseReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ class BaseReader
trusted_writer_entity_id_ = writer;
}

void allow_unknown_writers()
{
accept_messages_from_unkown_writers_ = true;
}

/**
* Whether the reader accepts messages directed to unknown readers.
*
Expand Down

0 comments on commit 258078d

Please sign in to comment.