diff --git a/third-party/realdds/include/realdds/dds-participant.h b/third-party/realdds/include/realdds/dds-participant.h index c11b965d48b..ecd9aacbd41 100644 --- a/third-party/realdds/include/realdds/dds-participant.h +++ b/third-party/realdds/include/realdds/dds-participant.h @@ -39,6 +39,9 @@ class slice; namespace realdds { +class dds_adapter_watcher; + + // The starting point for any DDS interaction, a participant has a name and is the focal point for creating, destroying, // and managing other DDS objects. It defines the DDS domain (ID) in which every other object lives. // @@ -53,6 +56,7 @@ class dds_participant struct listener_impl; rsutils::json _settings; + std::shared_ptr< dds_adapter_watcher > _adapter_watcher; public: dds_participant() = default; @@ -71,6 +75,12 @@ class dds_participant qos( std::string const & participant_name ); }; + // Return the QoS (so user won't have to actually know about the DomainParticipant) + eprosima::fastdds::dds::DomainParticipantQos const & get_qos() const; + + // Refresh the QoS, so it will pick up any changes in the system (e.g., if adapters have changed) + void refresh_qos(); + // Creates the underlying DDS participant and sets the QoS. // If callbacks are needed, set them before calling init. Note they may be called before init returns! // diff --git a/third-party/realdds/src/dds-participant.cpp b/third-party/realdds/src/dds-participant.cpp index d9366fcf9a8..6d68b64cdc1 100644 --- a/third-party/realdds/src/dds-participant.cpp +++ b/third-party/realdds/src/dds-participant.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -209,6 +210,10 @@ dds_participant::qos::qos( std::string const & participant_name ) //udp_transport->maxMessageSize = 1470; TODO this affects reading, too! We need writer-only property for this... transport().use_builtin_transports = false; transport().user_transports.push_back( udp_transport ); + + // If the user has many local interfaces (possible: I have 5!) then anything over the limit will not get + // communicated and end-point discovery will be affected. We want to avoid this so increase the limit: + allocation().locators.max_unicast_locators = 10; } @@ -253,6 +258,13 @@ void dds_participant::init( dds_domain_id domain_id, qos & pqos, rsutils::json c else DDS_THROW( runtime_error, "provided settings are invalid: " << settings ); + _adapter_watcher = std::make_shared< dds_adapter_watcher >( + [this] + { + LOG_DEBUG( name() << ": refreshing QoS" ); + refresh_qos(); + } ); + LOG_DEBUG( "participant " << realdds::print_raw_guid( guid() ) << " " << pqos << "\nis up on domain " << domain_id << " from settings: " << std::setw( 4 ) << _settings ); @@ -293,9 +305,15 @@ dds_domain_id dds_participant::domain_id() const } +eprosima::fastdds::dds::DomainParticipantQos const & dds_participant::get_qos() const +{ + return get()->get_qos(); +} + + rsutils::string::slice dds_participant::name() const { - auto & string_255 = get()->get_qos().name(); + auto & string_255 = get_qos().name(); return rsutils::string::slice( string_255.c_str(), string_255.size() ); } @@ -303,7 +321,7 @@ rsutils::string::slice dds_participant::name() const std::shared_ptr< const eprosima::fastdds::rtps::FlowControllerDescriptor > dds_participant::find_flow_controller( char const * name ) const { - for( auto & controller : get()->get_qos().flow_controllers() ) + for( auto & controller : get_qos().flow_controllers() ) { if( ! strcmp( name, controller->name ) ) return controller; @@ -312,6 +330,12 @@ dds_participant::find_flow_controller( char const * name ) const } +void dds_participant::refresh_qos() +{ + get()->set_qos( get_qos() ); +} + + std::string dds_participant::print( dds_guid const & guid_to_print ) const { return rsutils::string::from( realdds::print_guid( guid_to_print, guid() ) );