From c3127646a3da91f56fced43b0d794f9cc9df7e52 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 11 Jun 2019 11:22:02 -0500 Subject: [PATCH 1/8] Problem: Create topic fails for multiple participants in same process When using RTPS, multiple participants in different processes can create inconsistent topics. However, when the participants are in the same process, an inconsistent topic cannot be created. Solution: Force all knowledge of topics to the endpoint manager of discovery. --- dds/DCPS/Discovery.h | 1 + dds/DCPS/DiscoveryBase.h | 142 +++++++----------- dds/DCPS/DomainParticipantImpl.cpp | 1 + .../InfoRepoDiscovery/InfoRepoDiscovery.cpp | 7 +- .../InfoRepoDiscovery/InfoRepoDiscovery.h | 1 + dds/DCPS/RTPS/Sedp.cpp | 5 +- dds/DCPS/RTPS/Sedp.h | 3 +- dds/DCPS/StaticDiscovery.cpp | 3 +- dds/DCPS/StaticDiscovery.h | 3 +- 9 files changed, 67 insertions(+), 99 deletions(-) diff --git a/dds/DCPS/Discovery.h b/dds/DCPS/Discovery.h index 38b62244c81..46cc04d0734 100644 --- a/dds/DCPS/Discovery.h +++ b/dds/DCPS/Discovery.h @@ -132,6 +132,7 @@ class OpenDDS_Dcps_Export Discovery : public RcObject { virtual TopicStatus find_topic( DDS::DomainId_t domainId, + const RepoId& participantId, const char* topicName, CORBA::String_out dataTypeName, DDS::TopicQos_out qos, diff --git a/dds/DCPS/DiscoveryBase.h b/dds/DCPS/DiscoveryBase.h index 8be99d5490c..de334f19cef 100644 --- a/dds/DCPS/DiscoveryBase.h +++ b/dds/DCPS/DiscoveryBase.h @@ -319,12 +319,36 @@ namespace OpenDDS { return DCPS::CREATED; } - DCPS::TopicStatus remove_topic(const RepoId& topicId, OPENDDS_STRING& name) + DCPS::TopicStatus find_topic(const char* topicName, + CORBA::String_out dataTypeName, + DDS::TopicQos_out qos, + OpenDDS::DCPS::RepoId_out topicId) { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); - name = topic_names_[topicId]; - typename OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator top_it = - topics_.find(name); + typename OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::const_iterator iter = + topics_.find(topicName); + if (iter == topics_.end()) { + return DCPS::NOT_FOUND; + } + + const TopicDetails& td = iter->second; + + dataTypeName = td.data_type_.c_str(); + qos = new DDS::TopicQos(td.qos_); + topicId = td.repo_id_; + return DCPS::FOUND; + } + + DCPS::TopicStatus remove_topic(const RepoId& topicId) + { + ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); + TopicNameMap::iterator name_iter = topic_names_.find(topicId); + if (name_iter == topic_names_.end()) { + // TODO: What is the correct recturn value? + } + const OPENDDS_STRING& name = name_iter->second; + + typename OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator top_it = topics_.find(name); if (top_it != topics_.end()) { TopicDetails& td = top_it->second; if (td.endpoints_.empty()) { @@ -332,12 +356,11 @@ namespace OpenDDS { } } - topic_names_.erase(topicId); + topic_names_.erase(name_iter); return DCPS::REMOVED; } - virtual bool update_topic_qos(const DCPS::RepoId& topicId, const DDS::TopicQos& qos, - OPENDDS_STRING& name) = 0; + virtual bool update_topic_qos(const DCPS::RepoId& topicId, const DDS::TopicQos& qos) = 0; DCPS::RepoId add_publication(const DCPS::RepoId& topicId, DCPS::DataWriterCallbacks* publication, @@ -1423,9 +1446,18 @@ namespace OpenDDS { } DCPS::TopicStatus - remove_topic(const RepoId& topicId, OPENDDS_STRING& name) + find_topic(const char* topicName, + CORBA::String_out dataTypeName, + DDS::TopicQos_out qos, + OpenDDS::DCPS::RepoId_out topicId) { - return endpoint_manager().remove_topic(topicId, name); + return endpoint_manager().find_topic(topicName, dataTypeName, qos, topicId); + } + + DCPS::TopicStatus + remove_topic(const RepoId& topicId) + { + return endpoint_manager().remove_topic(topicId); } void @@ -1436,10 +1468,9 @@ namespace OpenDDS { } bool - update_topic_qos(const RepoId& topicId, const DDS::TopicQos& qos, - OPENDDS_STRING& name) + update_topic_qos(const RepoId& topicId, const DDS::TopicQos& qos) { - return endpoint_manager().update_topic_qos(topicId, qos, name); + return endpoint_manager().update_topic_qos(topicId, qos); } RepoId @@ -1791,56 +1822,22 @@ namespace OpenDDS { bool hasDcpsKey) { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); - typename OPENDDS_MAP(DDS::DomainId_t, - OPENDDS_MAP(OPENDDS_STRING, TopicDetails) )::iterator topic_it = - topics_.find(domainId); - if (topic_it != topics_.end()) { - const typename OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator it = - topic_it->second.find(topicName); - if (it != topic_it->second.end() - && it->second.data_type_ != dataTypeName) { - topicId = GUID_UNKNOWN; - return DCPS::CONFLICTING_TYPENAME; - } - } // Verified its safe to hold lock during call to assert_topic - const DCPS::TopicStatus stat = - participants_[domainId][participantId]->assert_topic(topicId, topicName, - dataTypeName, qos, - hasDcpsKey); - if (stat == DCPS::CREATED || stat == DCPS::FOUND) { // qos change (FOUND) - TopicDetails& td = topics_[domainId][topicName]; - td.data_type_ = dataTypeName; - td.qos_ = qos; - td.repo_id_ = topicId; - ++topic_use_[domainId][topicName]; - } - return stat; + return participants_[domainId][participantId]->assert_topic(topicId, topicName, + dataTypeName, qos, + hasDcpsKey); } - virtual DCPS::TopicStatus find_topic(DDS::DomainId_t domainId, const char* topicName, - CORBA::String_out dataTypeName, DDS::TopicQos_out qos, + virtual DCPS::TopicStatus find_topic(DDS::DomainId_t domainId, + const OpenDDS::DCPS::RepoId& participantId, + const char* topicName, + CORBA::String_out dataTypeName, + DDS::TopicQos_out qos, OpenDDS::DCPS::RepoId_out topicId) { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); - typename OPENDDS_MAP(DDS::DomainId_t, - OPENDDS_MAP(OPENDDS_STRING, TopicDetails) )::iterator topic_it = - topics_.find(domainId); - if (topic_it == topics_.end()) { - return DCPS::NOT_FOUND; - } - typename OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator iter = - topic_it->second.find(topicName); - if (iter == topic_it->second.end()) { - return DCPS::NOT_FOUND; - } - TopicDetails& td = iter->second; - dataTypeName = td.data_type_.c_str(); - qos = new DDS::TopicQos(td.qos_); - topicId = td.repo_id_; - ++topic_use_[domainId][topicName]; - return DCPS::FOUND; + return participants_[domainId][participantId]->find_topic(topicName, dataTypeName, qos, topicId); } virtual DCPS::TopicStatus remove_topic(DDS::DomainId_t domainId, @@ -1848,31 +1845,8 @@ namespace OpenDDS { const OpenDDS::DCPS::RepoId& topicId) { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); - typename OPENDDS_MAP(DDS::DomainId_t, - OPENDDS_MAP(OPENDDS_STRING, TopicDetails) )::iterator topic_it = - topics_.find(domainId); - if (topic_it == topics_.end()) { - return DCPS::NOT_FOUND; - } - - OPENDDS_STRING name; // Safe to hold lock while calling remove topic - const DCPS::TopicStatus stat = - participants_[domainId][participantId]->remove_topic(topicId, name); - - if (stat == DCPS::REMOVED) { - if (0 == --topic_use_[domainId][name]) { - topic_use_[domainId].erase(name); - if (topic_it->second.empty()) { - topic_use_.erase(domainId); - } - topic_it->second.erase(name); - if (topic_it->second.empty()) { - topics_.erase(topic_it); - } - } - } - return stat; + return participants_[domainId][participantId]->remove_topic(topicId); } virtual bool ignore_topic(DDS::DomainId_t domainId, const OpenDDS::DCPS::RepoId& myParticipantId, @@ -1886,14 +1860,8 @@ namespace OpenDDS { const OpenDDS::DCPS::RepoId& participantId, const DDS::TopicQos& qos) { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, false); - OPENDDS_STRING name; // Safe to hold lock while calling update_topic_qos - if (participants_[domainId][participantId]->update_topic_qos(topicId, - qos, name)) { - topics_[domainId][name].qos_ = qos; - return true; - } - return false; + return participants_[domainId][participantId]->update_topic_qos(topicId, qos); } virtual OpenDDS::DCPS::RepoId add_publication(DDS::DomainId_t domainId, @@ -2073,8 +2041,6 @@ namespace OpenDDS { } reactor_runner_; DomainParticipantMap participants_; - OPENDDS_MAP(DDS::DomainId_t, OPENDDS_MAP(OPENDDS_STRING, TopicDetails) ) topics_; - OPENDDS_MAP(DDS::DomainId_t, OPENDDS_MAP(OPENDDS_STRING, unsigned int) ) topic_use_; }; } // namespace DCPS diff --git a/dds/DCPS/DomainParticipantImpl.cpp b/dds/DCPS/DomainParticipantImpl.cpp index aa290d8a88e..ab994280f44 100644 --- a/dds/DCPS/DomainParticipantImpl.cpp +++ b/dds/DCPS/DomainParticipantImpl.cpp @@ -668,6 +668,7 @@ DomainParticipantImpl::find_topic( Discovery_rch disco = TheServiceParticipant->get_discovery(domain_id_); TopicStatus status = disco->find_topic(domain_id_, + get_id(), topic_name, type_name.out(), qos.out(), diff --git a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp index 122384964db..24dbd8f062e 100644 --- a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp +++ b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.cpp @@ -538,8 +538,11 @@ InfoRepoDiscovery::assert_topic(DCPS::RepoId_out topicId, DDS::DomainId_t domain } DCPS::TopicStatus -InfoRepoDiscovery::find_topic(DDS::DomainId_t domainId, const char* topicName, - CORBA::String_out dataTypeName, DDS::TopicQos_out qos, +InfoRepoDiscovery::find_topic(DDS::DomainId_t domainId, + const DCPS::RepoId& /*participantId*/, + const char* topicName, + CORBA::String_out dataTypeName, + DDS::TopicQos_out qos, DCPS::RepoId_out topicId) { try { diff --git a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h index 9a83fa29416..450fc40aef3 100644 --- a/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h +++ b/dds/DCPS/InfoRepoDiscovery/InfoRepoDiscovery.h @@ -126,6 +126,7 @@ class OpenDDS_InfoRepoDiscovery_Export InfoRepoDiscovery : public Discovery { virtual OpenDDS::DCPS::TopicStatus find_topic( DDS::DomainId_t domainId, + const OpenDDS::DCPS::RepoId& participantId, const char* topicName, CORBA::String_out dataTypeName, DDS::TopicQos_out qos, diff --git a/dds/DCPS/RTPS/Sedp.cpp b/dds/DCPS/RTPS/Sedp.cpp index d2d3fb4c1b1..ed6ce89a4e2 100644 --- a/dds/DCPS/RTPS/Sedp.cpp +++ b/dds/DCPS/RTPS/Sedp.cpp @@ -1418,8 +1418,7 @@ Sedp::sub_bit() #endif /* DDS_HAS_MINIMUM_BIT */ bool -Sedp::update_topic_qos(const RepoId& topicId, const DDS::TopicQos& qos, - OPENDDS_STRING& name) +Sedp::update_topic_qos(const RepoId& topicId, const DDS::TopicQos& qos) { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, false); OPENDDS_MAP_CMP(RepoId, OPENDDS_STRING, DCPS::GUID_tKeyLessThan)::iterator iter = @@ -1427,7 +1426,7 @@ Sedp::update_topic_qos(const RepoId& topicId, const DDS::TopicQos& qos, if (iter == topic_names_.end()) { return false; } - name = iter->second; + const OPENDDS_STRING& name = iter->second; TopicDetails& topic = topics_[name]; using namespace DCPS; // If the TOPIC_DATA QoS changed our local endpoints must be resent diff --git a/dds/DCPS/RTPS/Sedp.h b/dds/DCPS/RTPS/Sedp.h index 699eb8663c9..ae97d1064c3 100644 --- a/dds/DCPS/RTPS/Sedp.h +++ b/dds/DCPS/RTPS/Sedp.h @@ -128,8 +128,7 @@ class Sedp : public DCPS::EndpointManager { DDS::ReturnCode_t write_dcps_participant_dispose(const DCPS::RepoId& part); // Topic - bool update_topic_qos(const DCPS::RepoId& topicId, const DDS::TopicQos& qos, - OPENDDS_STRING& name); + bool update_topic_qos(const DCPS::RepoId& topicId, const DDS::TopicQos& qos); // Publication bool update_publication_qos(const DCPS::RepoId& publicationId, diff --git a/dds/DCPS/StaticDiscovery.cpp b/dds/DCPS/StaticDiscovery.cpp index 23b9790d4ef..c683c231d69 100644 --- a/dds/DCPS/StaticDiscovery.cpp +++ b/dds/DCPS/StaticDiscovery.cpp @@ -244,8 +244,7 @@ void StaticEndpointManager::assign_subscription_key(RepoId& rid, bool StaticEndpointManager::update_topic_qos(const RepoId& /*topicId*/, - const DDS::TopicQos& /*qos*/, - OPENDDS_STRING& /*name*/) + const DDS::TopicQos& /*qos*/) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: StaticEndpointManager::update_topic_qos - ") ACE_TEXT("Not allowed\n"))); diff --git a/dds/DCPS/StaticDiscovery.h b/dds/DCPS/StaticDiscovery.h index faf983be194..c7ddddd1887 100644 --- a/dds/DCPS/StaticDiscovery.h +++ b/dds/DCPS/StaticDiscovery.h @@ -150,8 +150,7 @@ class StaticEndpointManager const DDS::DataReaderQos& qos); virtual bool update_topic_qos(const RepoId& /*topicId*/, - const DDS::TopicQos& /*qos*/, - OPENDDS_STRING& /*name*/); + const DDS::TopicQos& /*qos*/); virtual bool update_publication_qos(const RepoId& /*publicationId*/, const DDS::DataWriterQos& /*qos*/, From fe099d8215d1b3371e58b7050e0e7ff781744748 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Mon, 17 Jun 2019 10:52:14 -0500 Subject: [PATCH 2/8] Problem: Builtin topics not updated when inconsistent topic When the logic in SEDP detects an inconsistent topic, it returns before updating the builtin topics. Solution: Continue processing when an inconsistent topic is discovered. --- dds/DCPS/RTPS/Sedp.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/dds/DCPS/RTPS/Sedp.cpp b/dds/DCPS/RTPS/Sedp.cpp index ed6ce89a4e2..4ed7ae87119 100644 --- a/dds/DCPS/RTPS/Sedp.cpp +++ b/dds/DCPS/RTPS/Sedp.cpp @@ -1764,6 +1764,7 @@ void Sedp::process_discovered_writer_data(DCPS::MessageId message_id, #endif DiscoveredPublication& pub = discovered_publications_[guid] = prepub; + bool inconsistent = false; OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator top_it = topics_.find(topic_name); @@ -1787,12 +1788,14 @@ void Sedp::process_discovered_writer_data(DCPS::MessageId message_id, wdata.ddsPublicationData.type_name.in(), top_it->second.data_type_.c_str())); } - return; + inconsistent = true; } - TopicDetails& td = top_it->second; - topic_names_[td.repo_id_] = topic_name; - td.endpoints_.insert(guid); + if (!inconsistent) { + TopicDetails& td = top_it->second; + topic_names_[td.repo_id_] = topic_name; + td.endpoints_.insert(guid); + } std::memcpy(pub.writer_data_.ddsPublicationData.participant_key.value, guid.guidPrefix, sizeof(DDS::BuiltinTopicKey_t)); @@ -2085,6 +2088,7 @@ void Sedp::process_discovered_reader_data(DCPS::MessageId message_id, #endif DiscoveredSubscription& sub = discovered_subscriptions_[guid] = presub; + bool inconsistent = false; OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator top_it = topics_.find(topic_name); @@ -2108,12 +2112,14 @@ void Sedp::process_discovered_reader_data(DCPS::MessageId message_id, rdata.ddsSubscriptionData.type_name.in(), top_it->second.data_type_.c_str())); } - return; + inconsistent = true; } - TopicDetails& td = top_it->second; - topic_names_[td.repo_id_] = topic_name; - td.endpoints_.insert(guid); + if (!inconsistent) { + TopicDetails& td = top_it->second; + topic_names_[td.repo_id_] = topic_name; + td.endpoints_.insert(guid); + } std::memcpy(sub.reader_data_.ddsSubscriptionData.participant_key.value, guid.guidPrefix, sizeof(DDS::BuiltinTopicKey_t)); From ec2cec68a622f7876fb6968894b17f8ed0783744 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Mon, 10 Jun 2019 11:26:43 -0500 Subject: [PATCH 3/8] Problem: InconsistentTopic test fails sporadically Solution: Rewrite as single-process that uses builtin topics to avoid sleeps. --- bin/dcps_tests.lst | 2 +- tests/DCPS/InconsistentTopic/.gitignore | 3 +- .../InconsistentTopic/InconsistentTopic.mpc | 21 +- tests/DCPS/InconsistentTopic/publisher.cpp | 131 ---------- tests/DCPS/InconsistentTopic/pubsub.cpp | 237 ++++++++++++++++++ tests/DCPS/InconsistentTopic/rtps_disc.ini | 12 +- tests/DCPS/InconsistentTopic/run_test.pl | 6 +- tests/DCPS/InconsistentTopic/subscriber.cpp | 139 ---------- 8 files changed, 256 insertions(+), 295 deletions(-) delete mode 100644 tests/DCPS/InconsistentTopic/publisher.cpp create mode 100644 tests/DCPS/InconsistentTopic/pubsub.cpp delete mode 100644 tests/DCPS/InconsistentTopic/subscriber.cpp diff --git a/bin/dcps_tests.lst b/bin/dcps_tests.lst index 4fa736a5d45..74a269f83c4 100644 --- a/bin/dcps_tests.lst +++ b/bin/dcps_tests.lst @@ -49,7 +49,7 @@ tests/DCPS/LivelinessTest/run_test.pl rtps_disc: !DCPS_MIN !DDS_NO_OWNERSHIP_PRO tests/DCPS/LivelinessTest/run_test.pl rtps_disc take: !DCPS_MIN !DDS_NO_OWNERSHIP_PROFILE RTPS tests/DCPS/Inconsistent_Qos/run_test.pl: RTPS XERCES3 !STATIC -tests/DCPS/InconsistentTopic/run_test.pl rtps_disc: RTPS +tests/DCPS/InconsistentTopic/run_test.pl rtps_disc: RTPS !NO_BUILT_IN_TOPICS tests/DCPS/TopicReuse/run_test.pl: RTPS tests/DCPS/DpShutdown/run_test.pl: RTPS tests/DCPS/Serializer/run_test.pl: !DCPS_MIN diff --git a/tests/DCPS/InconsistentTopic/.gitignore b/tests/DCPS/InconsistentTopic/.gitignore index b3f03f80482..2e881d65bff 100644 --- a/tests/DCPS/InconsistentTopic/.gitignore +++ b/tests/DCPS/InconsistentTopic/.gitignore @@ -1,8 +1,6 @@ /MessengerTypeSupportImpl.cpp /MessengerTypeSupport.idl -/publisher /MessengerTypeSupportImpl.h -/subscriber /MessengerTypeSupportC.h /MessengerC.h /MessengerTypeSupportS.h @@ -15,3 +13,4 @@ /MessengerTypeSupportS.cpp /MessengerS.inl /MessengerS.cpp +/pubsub \ No newline at end of file diff --git a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc index a23fee64de8..738541ef9a2 100644 --- a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc +++ b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc @@ -10,29 +10,16 @@ project(DDS*idl): dcps_test_lib { } } - -project(DDS*Publisher) : dcpsexe, dcps_transports_for_test { - exename = publisher - after += DDS*idl - libs += DDS*idl - - Idl_Files { - } - - Source_Files { - publisher.cpp - } -} - -project(DDS*Subscriber) : dcpsexe, dcps_transports_for_test { - exename = subscriber +project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { + exename = pubsub after += DDS*idl libs += DDS*idl + requires += built_in_topics Idl_Files { } Source_Files { - subscriber.cpp + pubsub.cpp } } diff --git a/tests/DCPS/InconsistentTopic/publisher.cpp b/tests/DCPS/InconsistentTopic/publisher.cpp deleted file mode 100644 index 312d35d548e..00000000000 --- a/tests/DCPS/InconsistentTopic/publisher.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// -*- C++ -*- -// ============================================================================ -/** - * @file publisher.cpp - */ -// ============================================================================ - -#include "MessengerTypeSupportImpl.h" -#include -#include -#include -#include "dds/DCPS/StaticIncludes.h" -#ifdef ACE_AS_STATIC_LIBS -#include -#include -#endif - -#include -#include "tests/Utils/ExceptionStreams.h" -#include "ace/Get_Opt.h" -#include "ace/OS_NS_unistd.h" - -using namespace Messenger; -using namespace std; - - -int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { - try - { - DDS::DomainParticipantFactory_var dpf = - TheParticipantFactoryWithArgs(argc, argv); - DDS::DomainParticipant_var participant = - dpf->create_participant(111, - PARTICIPANT_QOS_DEFAULT, - DDS::DomainParticipantListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (participant.in ())) { - cerr << "create_participant failed." << endl; - return 1; - } - - Message2TypeSupport_var mts = new Message2TypeSupportImpl(); - - if (DDS::RETCODE_OK != mts->register_type(participant.in (), "")) { - cerr << "register_type failed." << endl; - exit(1); - } - - CORBA::String_var type_name = mts->get_type_name (); - - DDS::Topic_var topic = - participant->create_topic ("Movie Discussion List", - type_name.in (), - TOPIC_QOS_DEFAULT, - DDS::TopicListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (topic.in ())) { - cerr << "create_topic failed." << endl; - exit(1); - } - - DDS::Publisher_var pub = - participant->create_publisher(PUBLISHER_QOS_DEFAULT, - DDS::PublisherListener::_nil(), ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (pub.in ())) { - cerr << "create_publisher failed." << endl; - exit(1); - } - - // Create the datawriter - DDS::DataWriter_var dw = - pub->create_datawriter(topic.in (), - DATAWRITER_QOS_DEFAULT, - DDS::DataWriterListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (dw.in ())) { - cerr << "create_datawriter failed." << endl; - exit(1); - } - - // Try to get the inconsistent_topic_status once a second for a number of seconds, when we got it - // we can stop getting it - DDS::InconsistentTopicStatus status; - for (size_t i = 0; i < 10; ++i) { - DDS::Duration_t timeout; - timeout.sec = 0; - timeout.nanosec = 0; - DDS::Topic_var topic2 = participant->find_topic ("Movie Discussion List", timeout); - if (CORBA::is_nil (topic2.in ())) { - cerr << "not able to find topic." << endl; - exit(1); - } - - DDS::ReturnCode_t const retcode = topic2->get_inconsistent_topic_status (status); - - if (retcode != DDS::RETCODE_OK) { - cerr << "not able to retrieve topic status." << endl; - exit(1); - } - - if (status.total_count_change != 0) { - cout << "publisher total_count_change not equal to zero, breaking loop after " << i << " iterations" << endl; - break; - } else { - cout << "publisher total_count_change zero, sleeping a second" << endl; - ACE_OS::sleep (1); - } - } - - if (status.total_count_change == 0) { - cerr << "publisher should have an inconsistent topic total count change not equal zero." << endl; - exit(1); - } else { - cout << "publisher total count: " << status.total_count << endl; - } - - ACE_OS::sleep (1); - - participant->delete_contained_entities(); - dpf->delete_participant(participant); - TheServiceParticipant->shutdown(); - } - catch (CORBA::Exception& e) - { - cerr << "PUB: Exception caught in main.cpp:" << endl - << e << endl; - exit(1); - } - - return 0; -} diff --git a/tests/DCPS/InconsistentTopic/pubsub.cpp b/tests/DCPS/InconsistentTopic/pubsub.cpp new file mode 100644 index 00000000000..a6a69dd0248 --- /dev/null +++ b/tests/DCPS/InconsistentTopic/pubsub.cpp @@ -0,0 +1,237 @@ +// -*- C++ -*- +// ============================================================================ +/** + * @file publisher.cpp + */ +// ============================================================================ + +#include "MessengerTypeSupportImpl.h" +#include +#include +#include +#include "dds/DCPS/StaticIncludes.h" +#include "dds/DCPS/BuiltInTopicUtils.h" +#include "dds/DCPS/transport/framework/TransportRegistry.h" +#ifdef ACE_AS_STATIC_LIBS +#include +#include +#endif + +#include +#include "tests/Utils/ExceptionStreams.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" + +using namespace Messenger; +using namespace std; + + +int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { + try + { + const char* topic = "Movie Discussion List"; + bool test_error = false; + + DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); + DDS::DomainParticipant_var p1 = dpf->create_participant(111, + PARTICIPANT_QOS_DEFAULT, + DDS::DomainParticipantListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(p1.in())) { + cerr << "ERROR: create_participant failed." << endl; + return 1; + } + OpenDDS::DCPS::TransportRegistry::instance()->bind_config("config_1", p1); + + DDS::Subscriber_var bit_subscriber1 = p1->get_builtin_subscriber() ; + DDS::DataReader_var bit_drg1 = bit_subscriber1->lookup_datareader(OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC); + DDS::SubscriptionBuiltinTopicDataDataReader_var bit_dr1 = DDS::SubscriptionBuiltinTopicDataDataReader::_narrow(bit_drg1); + + Message1TypeSupport_var mts1 = new Message1TypeSupportImpl(); + + if (DDS::RETCODE_OK != mts1->register_type(p1.in(), "")) { + cerr << "ERROR: register_type failed." << endl; + exit(1); + } + + CORBA::String_var type_name1 = mts1->get_type_name(); + + DDS::Topic_var topic1 = p1->create_topic(topic, + type_name1.in(), + TOPIC_QOS_DEFAULT, + DDS::TopicListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(topic1.in())) { + cerr << "ERROR: create_topic 1 failed." << endl; + exit(1); + } + + DDS::DomainParticipant_var p2 = dpf->create_participant(111, + PARTICIPANT_QOS_DEFAULT, + DDS::DomainParticipantListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(p2.in())) { + cerr << "ERROR: create_participant failed." << endl; + return 1; + } + + OpenDDS::DCPS::TransportRegistry::instance()->bind_config("config_2", p2); + + DDS::Subscriber_var bit_subscriber2 = p2->get_builtin_subscriber() ; + DDS::DataReader_var bit_drg2 = bit_subscriber2->lookup_datareader(OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC); + DDS::SubscriptionBuiltinTopicDataDataReader_var bit_dr2 = DDS::SubscriptionBuiltinTopicDataDataReader::_narrow(bit_drg2); + + Message2TypeSupport_var mts2 = new Message2TypeSupportImpl(); + + if (DDS::RETCODE_OK != mts2->register_type(p2.in(), "")) { + cerr << "ERROR: register_type failed." << endl; + exit(1); + } + + CORBA::String_var type_name2 = mts2->get_type_name(); + + DDS::Topic_var topic2 = + p2->create_topic(topic, + type_name2.in(), + TOPIC_QOS_DEFAULT, + DDS::TopicListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(topic2.in())) { + cerr << "ERROR: create_topic 2 failed." << endl; + exit(1); + } + + // At this point the participants and topics exist but have not + // been discovered since there are no readers or writers. + + DDS::Subscriber_var sub1 = + p1->create_subscriber(SUBSCRIBER_QOS_DEFAULT, + DDS::SubscriberListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(sub1.in())) { + cerr << "ERROR: Failed to create_subscriber." << endl; + exit(1); + } + + DDS::DataReader_var dr1 = sub1->create_datareader(topic1.in(), + DATAREADER_QOS_DEFAULT, + DDS::DataReaderListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(dr1.in())) { + cerr << "ERROR: create_datareader failed." << endl; + exit(1); + } + + // Wait for p2 to see p1's datareader. + + for (;;) { + DDS::SubscriptionBuiltinTopicDataSeq sub_data; + DDS::SampleInfoSeq infos; + DDS::ReturnCode_t ret = bit_dr2->read(sub_data, infos, 1, DDS::ANY_SAMPLE_STATE, DDS::ANY_VIEW_STATE, DDS::ANY_INSTANCE_STATE); + if (ret == DDS::RETCODE_OK) { + break; + } else { + cout << "Waiting for participant 2 to discover topic from participant 1 " << std::endl; + ACE_OS::sleep (1); + } + } + + // At this point, p2 should have an inconsistent topic and p1 + // will not. + + DDS::InconsistentTopicStatus status; + DDS::ReturnCode_t retcode; + + retcode = topic1->get_inconsistent_topic_status(status); + if (retcode != DDS::RETCODE_OK) { + cerr << "ERROR: not able to retrieve topic status." << endl; + exit(1); + } + if (status.total_count_change != 0) { + cerr << "ERROR: participant 1 saw an inconsistent topic when it should not (first)" << endl; + test_error = true; + } + + retcode = topic2->get_inconsistent_topic_status(status); + if (retcode != DDS::RETCODE_OK) { + cerr << "ERROR: not able to retrieve topic status." << endl; + exit(1); + } + if (status.total_count_change == 0) { + cerr << "ERROR: participant 2 did not see an inconsistent topic when it should have (first)" << endl; + test_error = true; + } + + DDS::Subscriber_var sub2 = + p2->create_subscriber(SUBSCRIBER_QOS_DEFAULT, + DDS::SubscriberListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(sub2.in())) { + cerr << "ERROR: Failed to create_subscriber." << endl; + exit(1); + } + + DDS::DataReader_var dr2 = sub2->create_datareader(topic2.in(), + DATAREADER_QOS_DEFAULT, + DDS::DataReaderListener::_nil(), + ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); + if (CORBA::is_nil(dr2.in())) { + cerr << "ERROR: create_datareader failed." << endl; + exit(1); + } + + // Wait for p2 to see p1's datareader. + + for (;;) { + DDS::SubscriptionBuiltinTopicDataSeq sub_data; + DDS::SampleInfoSeq infos; + DDS::ReturnCode_t ret = bit_dr1->read(sub_data, infos, 1, DDS::NOT_READ_SAMPLE_STATE, DDS::NEW_VIEW_STATE, DDS::ALIVE_INSTANCE_STATE); + if (ret == DDS::RETCODE_OK) { + break; + } else { + cout << "Waiting for participant 1 to discover topic from participant 2" << std::endl; + ACE_OS::sleep (1); + } + } + + retcode = topic1->get_inconsistent_topic_status(status); + if (retcode != DDS::RETCODE_OK) { + cerr << "ERROR: not able to retrieve topic status." << endl; + exit(1); + } + if (status.total_count_change == 0) { + cerr << "ERROR: participant 1 should have seen an inconsistent topic but did not (second)" << endl; + test_error = true; + } + + retcode = topic2->get_inconsistent_topic_status(status); + if (retcode != DDS::RETCODE_OK) { + cerr << "ERROR: not able to retrieve topic status." << endl; + exit(1); + } + if (status.total_count_change == 0) { + cerr << "ERROR: participant 2 should have seen an inconsistent topic but did not (second)" << endl; + test_error = true; + } + + p1->delete_contained_entities(); + dpf->delete_participant(p1); + + p2->delete_contained_entities(); + dpf->delete_participant(p2); + + TheServiceParticipant->shutdown(); + + if (test_error) { + exit(1); + } + } + catch (CORBA::Exception& e) + { + cerr << "ERROR: Exception caught in main.cpp:" << endl + << e << endl; + exit(1); + } + + return 0; +} diff --git a/tests/DCPS/InconsistentTopic/rtps_disc.ini b/tests/DCPS/InconsistentTopic/rtps_disc.ini index 567e58de0b0..40750827573 100644 --- a/tests/DCPS/InconsistentTopic/rtps_disc.ini +++ b/tests/DCPS/InconsistentTopic/rtps_disc.ini @@ -8,6 +8,16 @@ DiscoveryConfig=fast_rtps SedpMulticast=0 ResendPeriod=2 -[transport/the_rtps_transport] +[config/config_1] +transports=rtps_1 + +[config/config_2] +transports=rtps_2 + +[transport/rtps_1] +transport_type=rtps_udp +use_multicast=0 + +[transport/rtps_2] transport_type=rtps_udp use_multicast=0 diff --git a/tests/DCPS/InconsistentTopic/run_test.pl b/tests/DCPS/InconsistentTopic/run_test.pl index c17f47d31e5..45864c9decd 100755 --- a/tests/DCPS/InconsistentTopic/run_test.pl +++ b/tests/DCPS/InconsistentTopic/run_test.pl @@ -13,12 +13,10 @@ my $test = new PerlDDS::TestFramework(); -$test->process('sub', 'subscriber'); -$test->process('pub', 'publisher'); +$test->process('pubsub', 'pubsub'); $test->setup_discovery(); -$test->start_process('pub'); -$test->start_process('sub'); +$test->start_process('pubsub'); exit $test->finish(300); diff --git a/tests/DCPS/InconsistentTopic/subscriber.cpp b/tests/DCPS/InconsistentTopic/subscriber.cpp deleted file mode 100644 index b845b0ffe09..00000000000 --- a/tests/DCPS/InconsistentTopic/subscriber.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// -*- C++ -*- -// ============================================================================ -/** - * @file subscriber.cpp - */ -// ============================================================================ - - -#include "MessengerTypeSupportImpl.h" -#include -#include -#include -#include "dds/DCPS/StaticIncludes.h" -#ifdef ACE_AS_STATIC_LIBS -#include -#include -#endif - -#include -#include "tests/Utils/ExceptionStreams.h" -#include "ace/Get_Opt.h" -#include "ace/OS_NS_unistd.h" - -using namespace Messenger; -using namespace std; - -int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - try - { - DDS::DomainParticipantFactory_var dpf; - DDS::DomainParticipant_var participant; - - dpf = TheParticipantFactoryWithArgs(argc, argv); - participant = dpf->create_participant(111, - PARTICIPANT_QOS_DEFAULT, - DDS::DomainParticipantListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (participant.in ())) { - cerr << "create_participant failed." << endl; - return 1 ; - } - - Message1TypeSupport_var mts = new Message1TypeSupportImpl(); - - if (DDS::RETCODE_OK != mts->register_type(participant.in (), "")) { - cerr << "Failed to register the Message1TypeTypeSupport." << endl; - exit(1); - } - - CORBA::String_var type_name = mts->get_type_name (); - - DDS::Topic_var topic = participant->create_topic("Movie Discussion List", - type_name.in (), - TOPIC_QOS_DEFAULT, - DDS::TopicListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (topic.in ())) { - cerr << "Failed to create_topic." << endl; - exit(1); - } - - // Create the subscriber - DDS::Subscriber_var sub = - participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, - DDS::SubscriberListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (sub.in ())) { - cerr << "Failed to create_subscriber." << endl; - exit(1); - } - - // Create the Datareaders - DDS::DataReader_var dr = sub->create_datareader(topic.in (), - DATAREADER_QOS_DEFAULT, - DDS::DataReaderListener::_nil(), - ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); - if (CORBA::is_nil (dr.in ())) { - cerr << "create_datareader failed." << endl; - exit(1); - } - - // Try to get the inconsistent_topic_status once a second for a number of seconds, when we got it - // we can stop getting it - DDS::InconsistentTopicStatus status; - for (size_t i = 0; i < 10; ++i) { - DDS::Duration_t timeout; - timeout.sec = 0; - timeout.nanosec = 0; - DDS::Topic_var topic2 = participant->find_topic ("Movie Discussion List", timeout); - if (CORBA::is_nil (topic2.in ())) { - cerr << "not able to find topic." << endl; - exit(1); - } - - DDS::ReturnCode_t const retcode = topic2->get_inconsistent_topic_status (status); - - if (retcode != DDS::RETCODE_OK) { - cerr << "not able to retrieve topic status." << endl; - exit(1); - } - - if (status.total_count_change != 0) { - cout << "subscriber total_count_change not equal to zero, breaking loop after " << i << " iterations" << endl; - break; - } else { - cout << "subscriber total_count_change zero, sleeping a second" << endl; - ACE_OS::sleep (1); - } - - ACE_OS::sleep (1); - } - - if (status.total_count_change == 0) { - cerr << "subscriber should have an inconsistent topic total change count not equal zero." << endl; - exit(1); - } else { - cout << "subscriber total count: " << status.total_count << endl; - } - - ACE_OS::sleep (1); - - if (!CORBA::is_nil (participant.in ())) { - participant->delete_contained_entities(); - } - if (!CORBA::is_nil (dpf.in ())) { - dpf->delete_participant(participant.in ()); - } - - TheServiceParticipant->shutdown (); - } - catch (CORBA::Exception& e) - { - cerr << "SUB: Exception caught in main ():" << endl << e << endl; - return 1; - } - - return 0; -} From 84d62e07760c67d3212add37e6c0a98dedbe3041 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Mon, 17 Jun 2019 14:39:00 -0500 Subject: [PATCH 4/8] Incorporate changes from review --- dds/DCPS/DiscoveryBase.h | 2 +- tests/DCPS/InconsistentTopic/.gitignore | 2 +- .../InconsistentTopic/InconsistentTopic.mpc | 21 ++++++++++--------- tests/DCPS/InconsistentTopic/pubsub.cpp | 7 ------- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/dds/DCPS/DiscoveryBase.h b/dds/DCPS/DiscoveryBase.h index de334f19cef..8ed4b8d0da9 100644 --- a/dds/DCPS/DiscoveryBase.h +++ b/dds/DCPS/DiscoveryBase.h @@ -344,7 +344,7 @@ namespace OpenDDS { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); TopicNameMap::iterator name_iter = topic_names_.find(topicId); if (name_iter == topic_names_.end()) { - // TODO: What is the correct recturn value? + return DCPS::NOT_FOUND; } const OPENDDS_STRING& name = name_iter->second; diff --git a/tests/DCPS/InconsistentTopic/.gitignore b/tests/DCPS/InconsistentTopic/.gitignore index 2e881d65bff..ba8fa1691bd 100644 --- a/tests/DCPS/InconsistentTopic/.gitignore +++ b/tests/DCPS/InconsistentTopic/.gitignore @@ -13,4 +13,4 @@ /MessengerTypeSupportS.cpp /MessengerS.inl /MessengerS.cpp -/pubsub \ No newline at end of file +/pubsub diff --git a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc index 738541ef9a2..a4e06f825eb 100644 --- a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc +++ b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc @@ -1,14 +1,6 @@ -project(DDS*idl): dcps_test_lib { - idlflags += -Wb,stub_export_include=InconsistentTopic_export.h \ - -Wb,stub_export_macro=InconsistentTopic_Export -SS - dcps_ts_flags += -Wb,export_macro=InconsistentTopic_Export - dynamicflags += INCONSISTENTTOPIC_BUILD_DLL - - TypeSupport_Files { - Messenger.idl - } -} +//project(DDS*idl): dcps_test_lib { +//} project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { exename = pubsub @@ -22,4 +14,13 @@ project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { Source_Files { pubsub.cpp } + + idlflags += -Wb,stub_export_include=InconsistentTopic_export.h \ + -Wb,stub_export_macro=InconsistentTopic_Export -SS + dcps_ts_flags += -Wb,export_macro=InconsistentTopic_Export + dynamicflags += INCONSISTENTTOPIC_BUILD_DLL + + TypeSupport_Files { + Messenger.idl + } } diff --git a/tests/DCPS/InconsistentTopic/pubsub.cpp b/tests/DCPS/InconsistentTopic/pubsub.cpp index a6a69dd0248..01c1b6c4f7c 100644 --- a/tests/DCPS/InconsistentTopic/pubsub.cpp +++ b/tests/DCPS/InconsistentTopic/pubsub.cpp @@ -1,10 +1,3 @@ -// -*- C++ -*- -// ============================================================================ -/** - * @file publisher.cpp - */ -// ============================================================================ - #include "MessengerTypeSupportImpl.h" #include #include From bed88c83425e0ec4980483c3f161a0345dbab66d Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 18 Jun 2019 09:43:59 -0500 Subject: [PATCH 5/8] Incorporate changes from review --- tests/DCPS/InconsistentTopic/InconsistentTopic.mpc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc index a4e06f825eb..7fb1d0a922f 100644 --- a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc +++ b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc @@ -1,11 +1,6 @@ -//project(DDS*idl): dcps_test_lib { -//} - project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { exename = pubsub - after += DDS*idl - libs += DDS*idl requires += built_in_topics Idl_Files { @@ -15,11 +10,6 @@ project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { pubsub.cpp } - idlflags += -Wb,stub_export_include=InconsistentTopic_export.h \ - -Wb,stub_export_macro=InconsistentTopic_Export -SS - dcps_ts_flags += -Wb,export_macro=InconsistentTopic_Export - dynamicflags += INCONSISTENTTOPIC_BUILD_DLL - TypeSupport_Files { Messenger.idl } From d97f26e56c8ff1435ea8b4fc2e61d1ecd3051a5c Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 18 Jun 2019 10:16:15 -0500 Subject: [PATCH 6/8] Review --- .../InconsistentTopic/InconsistentTopic.mpc | 3 - .../InconsistentTopic_export.h | 57 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 tests/DCPS/InconsistentTopic/InconsistentTopic_export.h diff --git a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc index 7fb1d0a922f..d8cd7329550 100644 --- a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc +++ b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc @@ -3,9 +3,6 @@ project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { exename = pubsub requires += built_in_topics - Idl_Files { - } - Source_Files { pubsub.cpp } diff --git a/tests/DCPS/InconsistentTopic/InconsistentTopic_export.h b/tests/DCPS/InconsistentTopic/InconsistentTopic_export.h deleted file mode 100644 index 7b486d5abd3..00000000000 --- a/tests/DCPS/InconsistentTopic/InconsistentTopic_export.h +++ /dev/null @@ -1,57 +0,0 @@ - -// -*- C++ -*- -// Definition for Win32 Export directives. -// This file is generated automatically by generate_export_file.pl InconsistentTopic -// ------------------------------ -#ifndef INCONSISTENTTOPIC_EXPORT_H -#define INCONSISTENTTOPIC_EXPORT_H - -#include "ace/config-all.h" - -#if defined (ACE_AS_STATIC_LIBS) && !defined (INCONSISTENTTOPIC_HAS_DLL) -# define INCONSISTENTTOPIC_HAS_DLL 0 -#endif /* ACE_AS_STATIC_LIBS && INCONSISTENTTOPIC_HAS_DLL */ - -#if !defined (INCONSISTENTTOPIC_HAS_DLL) -# define INCONSISTENTTOPIC_HAS_DLL 1 -#endif /* ! INCONSISTENTTOPIC_HAS_DLL */ - -#if defined (INCONSISTENTTOPIC_HAS_DLL) && (INCONSISTENTTOPIC_HAS_DLL == 1) -# if defined (INCONSISTENTTOPIC_BUILD_DLL) -# define InconsistentTopic_Export ACE_Proper_Export_Flag -# define INCONSISTENTTOPIC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) -# define INCONSISTENTTOPIC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# else /* INCONSISTENTTOPIC_BUILD_DLL */ -# define InconsistentTopic_Export ACE_Proper_Import_Flag -# define INCONSISTENTTOPIC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) -# define INCONSISTENTTOPIC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -# endif /* INCONSISTENTTOPIC_BUILD_DLL */ -#else /* INCONSISTENTTOPIC_HAS_DLL == 1 */ -# define InconsistentTopic_Export -# define INCONSISTENTTOPIC_SINGLETON_DECLARATION(T) -# define INCONSISTENTTOPIC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) -#endif /* INCONSISTENTTOPIC_HAS_DLL == 1 */ - -// Set INCONSISTENTTOPIC_NTRACE = 0 to turn on library specific tracing even if -// tracing is turned off for ACE. -#if !defined (INCONSISTENTTOPIC_NTRACE) -# if (ACE_NTRACE == 1) -# define INCONSISTENTTOPIC_NTRACE 1 -# else /* (ACE_NTRACE == 1) */ -# define INCONSISTENTTOPIC_NTRACE 0 -# endif /* (ACE_NTRACE == 1) */ -#endif /* !INCONSISTENTTOPIC_NTRACE */ - -#if (INCONSISTENTTOPIC_NTRACE == 1) -# define INCONSISTENTTOPIC_TRACE(X) -#else /* (INCONSISTENTTOPIC_NTRACE == 1) */ -# if !defined (ACE_HAS_TRACE) -# define ACE_HAS_TRACE -# endif /* ACE_HAS_TRACE */ -# define INCONSISTENTTOPIC_TRACE(X) ACE_TRACE_IMPL(X) -# include "ace/Trace.h" -#endif /* (INCONSISTENTTOPIC_NTRACE == 1) */ - -#endif /* INCONSISTENTTOPIC_EXPORT_H */ - -// End of auto generated file. From cb9d338dd5706e5dcb90f5048d74fde28fd44f7e Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 18 Jun 2019 10:26:52 -0500 Subject: [PATCH 7/8] Review --- tests/DCPS/InconsistentTopic/InconsistentTopic.mpc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc index d8cd7329550..8cf2ea6c90d 100644 --- a/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc +++ b/tests/DCPS/InconsistentTopic/InconsistentTopic.mpc @@ -1,5 +1,5 @@ -project(DDS*PubblisherSubscriber) : dcpsexe, dcps_transports_for_test { +project(DDS*PublisherSubscriber) : dcpsexe, dcps_transports_for_test { exename = pubsub requires += built_in_topics From 5919fe5f447b9241cdc0899ae76c06f9dc72fcb3 Mon Sep 17 00:00:00 2001 From: "Justin R. Wilson" Date: Tue, 18 Jun 2019 15:11:50 -0500 Subject: [PATCH 8/8] Problem: Creating inconsistent topic in same participant succeeds This is only an issue in RTPS. Solution: Check for inconsistent topic when asserting topic with RTPS. --- dds/DCPS/DiscoveryBase.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dds/DCPS/DiscoveryBase.h b/dds/DCPS/DiscoveryBase.h index 8ed4b8d0da9..5e91575a42c 100644 --- a/dds/DCPS/DiscoveryBase.h +++ b/dds/DCPS/DiscoveryBase.h @@ -300,7 +300,10 @@ namespace OpenDDS { ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, DCPS::INTERNAL_ERROR); typename OPENDDS_MAP(OPENDDS_STRING, TopicDetails)::iterator iter = topics_.find(topicName); - if (iter != topics_.end()) { // types must match, RtpsDiscovery checked for us + if (iter != topics_.end()) { + if (iter->second.data_type_ != dataTypeName) { + return DCPS::CONFLICTING_TYPENAME; + } iter->second.qos_ = qos; iter->second.has_dcps_key_ = hasDcpsKey; topicId = iter->second.repo_id_;