From 8eeb28d9c45b1540ea2ba219d44a663a0959ffda Mon Sep 17 00:00:00 2001 From: msmit Date: Thu, 16 Jun 2011 08:36:49 +0000 Subject: Thu Jun 16 08:36:24 UTC 2011 Marcel Smit * connectors/dds4ccm/impl/ndds/TypeSupport.cpp: Fixed runtime issues in close. * connectors/dds4ccm/tests/TypeSupport/main.cpp: Expanded test with a few other tests. --- CIAO/ChangeLog | 8 ++ CIAO/connectors/dds4ccm/impl/ndds/TypeSupport.cpp | 22 +-- CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp | 155 ++++++++++++++++----- 3 files changed, 141 insertions(+), 44 deletions(-) diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index ec04dd97903..90f7088fc4d 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,11 @@ +Thu Jun 16 08:36:24 UTC 2011 Marcel Smit + + * connectors/dds4ccm/impl/ndds/TypeSupport.cpp: + Fixed runtime issues in close. + + * connectors/dds4ccm/tests/TypeSupport/main.cpp: + Expanded test with a few other tests. + Thu Jun 16 07:19:26 UTC 2011 Johnny Willemsen * connectors/dds4ccm/tests/ContentFilteredTopic/StateListener/Sender/CFTLS_Test_Sender_exec.cpp: diff --git a/CIAO/connectors/dds4ccm/impl/ndds/TypeSupport.cpp b/CIAO/connectors/dds4ccm/impl/ndds/TypeSupport.cpp index ad4468de9aa..8788e98ff73 100644 --- a/CIAO/connectors/dds4ccm/impl/ndds/TypeSupport.cpp +++ b/CIAO/connectors/dds4ccm/impl/ndds/TypeSupport.cpp @@ -105,8 +105,7 @@ namespace CIAO "DDS_TypeSupport_i::register_factory_i - " "Created new factory entry for type <%C>\n", type)); - // necessary to assign the type-factory combination to the correct - // DomainParticipant entry. + // assign the type-factory combination to the DomainParticipant entry. dp_entry->second = tf; return true; } @@ -129,14 +128,11 @@ namespace CIAO if (dp_entry != participant_factories.end()) { - // initialize every factory to nil typefactories tf = dp_entry->second; typefactories::iterator it = tf.find(type); if (it != tf.end()) { - it->second = 0; tf.erase(it); - if (tf.size () == 0UL) { // no more entries -> remove the participant from // the list @@ -148,6 +144,11 @@ namespace CIAO dp, type)); } + else + { + // assign the type-factory combination to the DomainParticipant entry. + dp_entry->second = tf; + } } else { @@ -163,7 +164,7 @@ namespace CIAO { DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO "DDS_TypeSupport_i::unregister_participant_factory_i - " - "Could not find the correct factory belonging to participant <%@>. " + "Could not find the entry for participant <%@>. " "Unable to remove.\n", dp)); } @@ -268,13 +269,12 @@ namespace CIAO ++i ) { typefactories tf = i->second; - for(typefactories::iterator j = tf.begin(); - j != tf.end(); - ++j ) + + for(size_t j = tf.size() - 1; j != 0; j--) { - delete j->second; - j->second = 0; + delete tf[j]; } + tf.clear(); } participant_factories.clear (); } diff --git a/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp b/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp index 65a6da93035..76fcad830ab 100644 --- a/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp +++ b/CIAO/connectors/dds4ccm/tests/TypeSupport/main.cpp @@ -36,6 +36,18 @@ ACE_TMAIN (int , ACE_TCHAR **) return 0; #endif + // first turn on or off tracing + ACE_Env_Value trace (ACE_TEXT("DDS4CCM_TRACE_ENABLE"), 0); + if (trace) + { + DDS4CCM_ENABLE_TRACE (); + } + else + { + DDS4CCM_DISABLE_TRACE (); + } + DDS4CCM_debug_level = 0; + int ret = 0; try @@ -61,9 +73,11 @@ ACE_TMAIN (int , ACE_TCHAR **) const char * type1 = "DataType1"; const char * type2 = "DataType2"; + const char * type3 = "DataType3"; TestTypeFactory * f1 = 0; TestTypeFactory * f2 = 0; + TestTypeFactory * f3 = 0; ACE_NEW_THROW_EX (f1, TestTypeFactory (), @@ -71,110 +85,185 @@ ACE_TMAIN (int , ACE_TCHAR **) ACE_NEW_THROW_EX (f2, TestTypeFactory (), ::CORBA::NO_MEMORY ()); + ACE_NEW_THROW_EX (f3, + TestTypeFactory (), + ::CORBA::NO_MEMORY ()); - - // Register the the first factory + /// Register type 1 with f1 if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type1, f1, dp1.in())) { - ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> for DP1 succesfully registered\n", - type1)); + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> and Factory <%@> for DP1 succesfully registered\n", + type1, f1)); } else { - ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> for DP1 could not be registered\n", - type1)); + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> and Factory <%@> for DP1 could not be registered\n", + type1, f1)); ++ret; } - // Register the same factory again + /// DP1 should now contain one type-factory combination + + /// Register the same factory again if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type1, f1, dp1.in())) { - ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> for DP1 could be registered\n", - type1)); + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> and Factory <%@> for DP1 could be registered\n", + type1, f1)); ++ret; } else { - ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> for DP1 could not be registered\n", - type1)); + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> and Factory <%@> for DP1 could not be registered\n", + type1, f1)); } - // Register the same factory again but with another name + /// DP1 should now contain one type-factory combination + + /// Register the same factory again but with another name if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type2, f1, dp1.in())) { - ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> for DP1 could be registered\n", - type2)); + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> and Factory <%@> for DP1 could be registered\n", + type2, f1)); } else { - ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> for DP1 could not be registered\n", - type2)); + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> and Factory <%@> for DP1 could not be registered\n", + type2, f1)); ++ret; } + /// DP1 should now contain two type-factory combinations - // Unregister an unused factory by using an unused domain participant + /// Register the same type with another factory + if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type2, f2, dp1.in())) + { + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> and Factory <%@> for DP1 could be registered\n", + type2, f2)); + ++ret; + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> and Factory <%@> for DP1 could not be registered\n", + type2, f2)); + } + /// DP1 should now contain two type-factory combinations + + /// Just register type 3 with f3 + if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type3, f3, dp1.in())) + { + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> and Factory <%@> for DP1 succesfully registered\n", + type3, f3)); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> and Factory <%@> for DP1 could not be registered\n", + type3, f3)); + ++ret; + } + /// DP1 should now contain three type-factory combinations + + + + /// Unregister an unused factory by using an unused domain participant ::CIAO::NDDS::DDS_TypeFactory_i * tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type1, dp2.in()); if (tmp) { ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP2 could be unregistered\n", - type2)); + type1)); ++ret; } else { - ACE_DEBUG ((LM_DEBUG, "OK - Unregistered Type <%C> for DP2 could not be unregistered\n", - type2)); + ACE_DEBUG ((LM_DEBUG, "OK - Unregistered type <%C> for DP2 could not be unregistered\n", + type1)); } - // Unregister a registered type by using a used domain participant + /// Unregister a registered type by using a used domain participant tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type1, dp1.in()); if (tmp) { ACE_DEBUG ((LM_DEBUG, "OK - Unregistered type <%C> for DP1 could be unregistered\n", - type2)); + type1)); } else { - ACE_ERROR ((LM_ERROR, "ERROR - Unregistered Type <%C> for DP1 could not be unregistered\n", - type2)); + ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP1 could not be unregistered\n", + type1)); ++ret; } + /// DP1 should now contain two type-factory combinations - // Unregister a the same type and domain participant again + /// Unregister a the same type and domain participant again tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type1, dp1.in()); if (tmp) { ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP1 could be unregistered\n", - type2)); + type1)); ++ret; } else { - ACE_DEBUG ((LM_DEBUG, "OK - Unregistered Type <%C> for DP1 could not be unregistered\n", - type2)); + ACE_DEBUG ((LM_DEBUG, "OK - Unregistered type <%C> for DP1 could not be unregistered\n", + type1)); } + /// DP1 should now contain two type-factory combinations - // Call Close on TypeSupport. This should remove the last remaining entry. + /// Call Close on TypeSupport. This should remove the last remaining entries. ::CIAO::NDDS::DDS_TypeSupport_i::close(); - // Unregister the type and domain participant which should be removed by 'close' + /// Unregister the type and domain participant which should be removed by 'close' tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type2, dp1.in()); if (tmp) { - ACE_ERROR ((LM_ERROR, "ERROR - Unregistered type <%C> for DP1 could be unregistered\n", + ACE_ERROR ((LM_ERROR, "ERROR - Deleted type <%C> for DP1 could be unregistered\n", type2)); ++ret; } else { - ACE_DEBUG ((LM_DEBUG, "OK - Unregistered Type <%C> for DP1 could not be unregistered\n", + ACE_DEBUG ((LM_DEBUG, "OK - Deleted type <%C> for DP1 could not be unregistered\n", type2)); } - delete f1; + /// Unregister the type and domain participant which should be removed by 'close' + tmp = ::CIAO::NDDS::DDS_TypeSupport_i::unregister_type(type3, dp1.in()); + + if (tmp) + { + ACE_ERROR ((LM_ERROR, "ERROR - Deleted type <%C> for DP1 could be unregistered\n", + type3)); + ++ret; + } + else + { + ACE_DEBUG ((LM_DEBUG, "OK - Deleted type <%C> for DP1 could not be unregistered\n", + type3)); + } + + /// We should now be able to register type 3 again + if (::CIAO::NDDS::DDS_TypeSupport_i::register_type(type3, f3, dp1.in())) + { + ACE_DEBUG ((LM_DEBUG, "OK - Type <%C> and Factory <%@> for DP1 succesfully registered\n", + type3, f3)); + } + else + { + ACE_ERROR ((LM_ERROR, "ERROR - Type <%C> and Factory <%@> for DP1 could not be registered\n", + type3, f3)); + ++ret; + } + /// DP1 should now contain one type-factory combination + + /// Call Close on TypeSupport. This should remove the last remaining entries. + ::CIAO::NDDS::DDS_TypeSupport_i::close(); + + delete f3; delete f2; + delete f1; + + pf.delete_participant(dp1); + pf.delete_participant(dp2); } catch (const ::CORBA::Exception& e) { -- cgit v1.2.1