diff options
author | msmit <msmit@remedy.nl> | 2010-11-29 10:51:34 +0000 |
---|---|---|
committer | msmit <msmit@remedy.nl> | 2010-11-29 10:51:34 +0000 |
commit | ef8c10579cde4dd6c1e3e0b67d9666343735b7b9 (patch) | |
tree | aa6ed3f224aa0145ee54d623efd869de450bdedf | |
parent | bc63881187217ed895226787b71a0ff66459f346 (diff) | |
download | ATCD-ef8c10579cde4dd6c1e3e0b67d9666343735b7b9.tar.gz |
Mon Nov 29 10:51:56 UTC 2010 Marcel Smit <msmit@remedy.nl>
* connectors/dds4ccm/impl/ConditionManager.cpp:
* connectors/dds4ccm/impl/DDS_Base_Connector_T.cpp:
* connectors/dds4ccm/impl/DDS_Subscriber_Base_T.cpp:
* connectors/dds4ccm/impl/DDS_TopicBase_Connector_T.cpp:
* connectors/dds4ccm/tests/MultiTopic/Connector/MultiTopic_Connector_T.cpp:
Shutting down the dds4ccm connector in a thread safe and memory leak free
manner.
6 files changed, 138 insertions, 55 deletions
diff --git a/CIAO/ChangeLog b/CIAO/ChangeLog index 97905114f8a..17245c8457c 100644 --- a/CIAO/ChangeLog +++ b/CIAO/ChangeLog @@ -1,3 +1,13 @@ +Mon Nov 29 10:51:56 UTC 2010 Marcel Smit <msmit@remedy.nl> + + * connectors/dds4ccm/impl/ConditionManager.cpp: + * connectors/dds4ccm/impl/DDS_Base_Connector_T.cpp: + * connectors/dds4ccm/impl/DDS_Subscriber_Base_T.cpp: + * connectors/dds4ccm/impl/DDS_TopicBase_Connector_T.cpp: + * connectors/dds4ccm/tests/MultiTopic/Connector/MultiTopic_Connector_T.cpp: + Shutting down the dds4ccm connector in a thread safe and memory leak free + manner. + Mon Nov 29 10:31:39 UTC 2010 Marijke Hengstmengel <mhengstmengel@remedy.nl> *bin/ciao_tests.lst: @@ -8,7 +18,7 @@ Mon Nov 29 10:15:39 UTC 2010 Marijke Hengstmengel <mhengstmengel@remedy.nl> * tests/IDL_Test/NonTopic_Connector/descriptors: * tests/IDL_Test/NonTopic_Connector/descriptors/DeploymentPlan.cdp: * tests/IDL_Test/NonTopic_Connector/descriptors/run_test.pl: - Add deployment and run script. + Add deployment and run script. Fri Nov 26 22:35:09 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu> diff --git a/CIAO/connectors/dds4ccm/impl/ConditionManager.cpp b/CIAO/connectors/dds4ccm/impl/ConditionManager.cpp index a964196a996..ed5f6bb09d3 100644 --- a/CIAO/connectors/dds4ccm/impl/ConditionManager.cpp +++ b/CIAO/connectors/dds4ccm/impl/ConditionManager.cpp @@ -348,13 +348,19 @@ namespace CIAO ::DDS::ReturnCode_t retcode = ::DDS::RETCODE_OK; if (! ::CORBA::is_nil (this->qc_reader_.in ())) { - this->remove_condition (this->qc_reader_.in (), "reader"); - this->qc_reader_ = ::DDS::QueryCondition::_nil (); + ::DDS::QueryCondition_var qc = this->qc_reader_._retn (); + if (!::CORBA::is_nil (qc.in ())) + { + this->remove_condition (qc.in (), "reader"); + } } if (! ::CORBA::is_nil (this->qc_listener_.in ())) { - this->remove_condition (this->qc_listener_.in (), "listener"); - this->qc_listener_ = ::DDS::QueryCondition::_nil (); + ::DDS::QueryCondition_var qc = this->qc_listener_._retn (); + if (!::CORBA::is_nil (qc.in ())) + { + this->remove_condition (qc.in (), "listener"); + } } if (this->ws_.get_rti_entity ()) @@ -367,8 +373,11 @@ namespace CIAO DDS4CCM_DEBUG (DDS4CCM_LOG_LEVEL_ACTION, (LM_INFO, DDS4CCM_INFO ACE_TEXT ("ConditionManager::remove_conditions - ") ACE_TEXT ("Query condition successfully detached from waitset.\n"))); - this->remove_condition (this->qc_getter_.in (), "getter"); - this->qc_getter_ = ::DDS::QueryCondition::_nil (); + ::DDS::QueryCondition_var qc = this->qc_getter_._retn (); + if (!::CORBA::is_nil (qc.in ())) + { + this->remove_condition (qc.in (), "getter"); + } } else { @@ -404,7 +413,12 @@ namespace CIAO } if (! ::CORBA::is_nil (this->rd_condition_.in ())) { - retcode = this->dds_entity ()->delete_readcondition (this->rd_condition_.in ()); + retcode = ::DDS::RETCODE_OK; + ::DDS::ReadCondition_var rd = this->rd_condition_._retn (); + if (!::CORBA::is_nil (rd.in ())) + { + retcode = this->dds_entity ()->delete_readcondition (rd.in ()); + } if (retcode != ::DDS::RETCODE_OK) { DDS4CCM_ERROR (DDS4CCM_LOG_LEVEL_ERROR, (LM_ERROR, DDS4CCM_INFO diff --git a/CIAO/connectors/dds4ccm/impl/DDS_Base_Connector_T.cpp b/CIAO/connectors/dds4ccm/impl/DDS_Base_Connector_T.cpp index 6e7abba8785..845905e831b 100644 --- a/CIAO/connectors/dds4ccm/impl/DDS_Base_Connector_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/DDS_Base_Connector_T.cpp @@ -205,8 +205,11 @@ DDS_Base_Connector_T<CCM_TYPE, DDS_TYPE>::ccm_remove (void) { DDS4CCM_TRACE ("DDS_Base_Connector_T<CCM_TYPE, DDS_TYPE>::ccm_remove"); - this->remove_domain (this->domain_participant_.in ()); - this->domain_participant_ = ::DDS::DomainParticipant::_nil (); + ::DDS::DomainParticipant_var dp = this->domain_participant_._retn (); + if (!::CORBA::is_nil (dp.in ())) + { + this->remove_domain (dp.in ()); + } } template <typename CCM_TYPE, typename DDS_TYPE> diff --git a/CIAO/connectors/dds4ccm/impl/DDS_Subscriber_Base_T.cpp b/CIAO/connectors/dds4ccm/impl/DDS_Subscriber_Base_T.cpp index 1e6a343c3d9..884f3869472 100644 --- a/CIAO/connectors/dds4ccm/impl/DDS_Subscriber_Base_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/DDS_Subscriber_Base_T.cpp @@ -135,7 +135,8 @@ DDS_Subscriber_Base_T<CCM_TYPE, TYPED_DDS_READER, VALUE_TYPE, SEQ_VALUE_TYPE>::p this->condition_manager_.passivate (); ::DDS::DataReader_var reader = this->dds_read_->get_dds_reader (); - if (!::CORBA::is_nil (this->listener_.in ()) && + ::DDS::DataReaderListener_var reader_listener = this->listener_._retn (); + if (!::CORBA::is_nil (reader_listener.in ()) && !::CORBA::is_nil (reader.in ()) ) { ::DDS::ReturnCode_t const retcode = @@ -148,7 +149,6 @@ DDS_Subscriber_Base_T<CCM_TYPE, TYPED_DDS_READER, VALUE_TYPE, SEQ_VALUE_TYPE>::p ::CIAO::DDS4CCM::translate_retcode (retcode))); throw ::CORBA::INTERNAL (); } - this->listener_ = ::DDS::DataReaderListener::_nil (); } } diff --git a/CIAO/connectors/dds4ccm/impl/DDS_TopicBase_Connector_T.cpp b/CIAO/connectors/dds4ccm/impl/DDS_TopicBase_Connector_T.cpp index 74f020e714b..a37219a9247 100644 --- a/CIAO/connectors/dds4ccm/impl/DDS_TopicBase_Connector_T.cpp +++ b/CIAO/connectors/dds4ccm/impl/DDS_TopicBase_Connector_T.cpp @@ -106,16 +106,29 @@ void DDS_TopicBase_Connector_T<CCM_TYPE, DDS_TYPE>::ccm_passivate (void) { DDS4CCM_TRACE ("DDS_TopicBase_Connector_T<CCM_TYPE, DDS_TYPE>::ccm_passivate"); - this->passivate_topic (this->topic_.in (), - this->topiclistener_.in ()); - this->passivate_subscriber (this->subscriber_.in (), - this->subscriber_listener_.in ()); - this->passivate_publisher (this->publisher_.in (), - this->publisher_listener_.inout ()); - - this->topiclistener_ = ::DDS::TopicListener::_nil (); - this->subscriber_listener_ = ::DDS::SubscriberListener::_nil (); - this->publisher_listener_ = ::DDS::PublisherListener::_nil (); + + ::DDS::TopicListener_var topiclistener = + this->topiclistener_._retn (); + if (! CORBA::is_nil (topiclistener.in ())) + { + this->passivate_topic (this->topic_.in (), + topiclistener.in ()); + } + ::DDS::SubscriberListener_var subscriber_listener = + this->subscriber_listener_._retn (); + if (! CORBA::is_nil (subscriber_listener.in ())) + { + this->passivate_subscriber (this->subscriber_.in (), + subscriber_listener.in ()); + } + ::DDS::PublisherListener_var publisher_listener = + this->publisher_listener_._retn (); + if (!::CORBA::is_nil (publisher_listener.in ())) + { + this->passivate_publisher (this->publisher_.in (), + publisher_listener.in ()); + } + BaseConnector::ccm_passivate (); } @@ -124,21 +137,29 @@ void DDS_TopicBase_Connector_T<CCM_TYPE, DDS_TYPE>::ccm_remove (void) { DDS4CCM_TRACE ("DDS_TopicBase_Connector_T<CCM_TYPE, DDS_TYPE>::ccm_remove"); - this->remove_topic (this->domain_participant_.in (), - this->topic_.in ()); + ::DDS::Topic_var topic = this->topic_._retn (); + if (! CORBA::is_nil (topic.in ())) + { + this->remove_topic (this->domain_participant_.in (), + topic.in ()); + } const char* typesupport_name = DDS_TYPE::type_support::get_type_name (); this->unregister_type (this->domain_participant_.in (), typesupport_name); - this->remove_subscriber (this->domain_participant_.in (), - this->subscriber_.in ()); - this->remove_publisher (this->domain_participant_.in (), - this->publisher_.in ()); - this->topic_ = ::DDS::Topic::_nil (); - this->publisher_ = ::DDS::Publisher::_nil (); - this->subscriber_ = ::DDS::Subscriber::_nil (); - + ::DDS::Subscriber_var subscriber = this->subscriber_._retn (); + if (! CORBA::is_nil (subscriber.in ())) + { + this->remove_subscriber (this->domain_participant_.in (), + subscriber.in ()); + } + ::DDS::Publisher_var publisher = this->publisher_._retn (); + if (!::CORBA::is_nil (publisher.in ())) + { + this->remove_publisher (this->domain_participant_.in (), + publisher); + } BaseConnector::ccm_remove (); } diff --git a/CIAO/connectors/dds4ccm/tests/MultiTopic/Connector/MultiTopic_Connector_T.cpp b/CIAO/connectors/dds4ccm/tests/MultiTopic/Connector/MultiTopic_Connector_T.cpp index ae0d4fdeced..333b49315ca 100644 --- a/CIAO/connectors/dds4ccm/tests/MultiTopic/Connector/MultiTopic_Connector_T.cpp +++ b/CIAO/connectors/dds4ccm/tests/MultiTopic/Connector/MultiTopic_Connector_T.cpp @@ -539,15 +539,24 @@ template <typename CCM_TYPE, typename DDS_TYPE, bool FIXED, typename SEQ_TYPE, b void DDS_MT_Event_Connector_T<CCM_TYPE, DDS_TYPE, FIXED, SEQ_TYPE, FIXED_SEQ_TYPE>::passivate_topics (void) { - this->passivate_topic (this->topic_sq_.in (), - this->topiclistener_sq_.in ()); - this->passivate_topic (this->topic_tr_.in (), - this->topiclistener_tr_.in ()); - this->passivate_topic (this->topic_cl_.in (), - this->topiclistener_cl_.in ()); - this->topiclistener_sq_ = ::DDS::TopicListener::_nil (); - this->topiclistener_tr_ = ::DDS::TopicListener::_nil (); - this->topiclistener_cl_ = ::DDS::TopicListener::_nil (); + ::DDS::TopicListener_var topic_listener = this->topiclistener_sq_._retn (); + if (!::CORBA::is_nil (topic_listener.in ())) + { + this->passivate_topic (this->topic_sq_.in (), + topic_listener.in ()); + } + topic_listener = this->topiclistener_tr_._retn (); + if (!::CORBA::is_nil (topic_listener.in ())) + { + this->passivate_topic (this->topic_tr_.in (), + topic_listener.in ()); + } + topic_listener = this->topiclistener_cl_._retn (); + if (!::CORBA::is_nil (topic_listener.in ())) + { + this->passivate_topic (this->topic_cl_.in (), + topic_listener.in ()); + } } template <typename CCM_TYPE, typename DDS_TYPE, bool FIXED, typename SEQ_TYPE, bool FIXED_SEQ_TYPE> @@ -565,12 +574,20 @@ DDS_MT_Event_Connector_T<CCM_TYPE, DDS_TYPE, FIXED, SEQ_TYPE, FIXED_SEQ_TYPE>::c this->passivate_topics (); - this->passivate_subscriber (this->subscriber_.in (), - this->subscriber_listener_.in ()); - this->passivate_publisher (this->publisher_.in (), - this->publisher_listener_.in ()); - this->subscriber_listener_ = ::DDS::SubscriberListener::_nil (); - this->publisher_listener_ = ::DDS::PublisherListener::_nil (); + ::DDS::SubscriberListener_var subscriber_listener = + this->subscriber_listener_._retn (); + if (!::CORBA::is_nil (subscriber_listener.in ())) + { + this->passivate_subscriber (this->subscriber_.in (), + subscriber_listener.in ()); + } + ::DDS::PublisherListener_var publisher_listener = + this->publisher_listener_._retn (); + if (!::CORBA::is_nil (publisher_listener.in ())) + { + this->passivate_publisher (this->publisher_.in (), + publisher_listener.in ()); + } } template <typename CCM_TYPE, typename DDS_TYPE, bool FIXED, typename SEQ_TYPE, bool FIXED_SEQ_TYPE> @@ -599,17 +616,35 @@ DDS_MT_Event_Connector_T<CCM_TYPE, DDS_TYPE, FIXED, SEQ_TYPE, FIXED_SEQ_TYPE>::c this->remove_topics (); - this->remove_publisher (this->domain_participant_.in (), - this->publisher_.in ()); - this->remove_subscriber (this->domain_participant_.in (), - this->subscriber_.in ()); + /** + * + * In order to close down in a thread safe and memory leak free manner, one + * should first declare a temporary _var variable and assign this one with the + * class member, using _retn (). This'll free all references to the class member + * so one's sure that the only one left is the temporary _var variable. This + * one should be used in calls to the 'remove_xxx' methods. + **/ + ::DDS::Publisher_var publisher = this->publisher_._retn (); + if (!::CORBA::is_nil (publisher.in ())) + { + this->remove_publisher (this->domain_participant_.in (), + publisher.in ()); + } + ::DDS::Subscriber_var subscriber = this->subscriber_._retn (); + if (!::CORBA::is_nil (subscriber.in ())) + { + this->remove_subscriber (this->domain_participant_.in (), + subscriber.in ()); + } + const char* typesupport_name = DDS_TYPE::type_support::get_type_name (); this->unregister_type (this->domain_participant_.in (), typesupport_name); - this->remove_domain (this->domain_participant_.in ()); + ::DDS::DomainParticipant_var dp = this->domain_participant_._retn (); + if (!::CORBA::is_nil (dp.in ())) + { + this->remove_domain (dp.in ()); + } - this->publisher_ = ::DDS::Publisher::_nil (); - this->subscriber_ = ::DDS::Subscriber::_nil (); - this->domain_participant_ = ::DDS::DomainParticipant::_nil (); } |