diff options
author | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-03-17 14:43:44 +0000 |
---|---|---|
committer | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-03-17 14:43:44 +0000 |
commit | d1ade733b03585fe72c9b41075f7a22538d1d066 (patch) | |
tree | 330833b9ecb81f8a275f288cd990761e262f4a98 | |
parent | 95dbc2d83f5c6315f01d65769088faf9fe6dc7c2 (diff) | |
download | ATCD-d1ade733b03585fe72c9b41075f7a22538d1d066.tar.gz |
Merged revisions 80955-80956,80958-80962,80964-80974 via svnmerge from
https://svn.dre.vanderbilt.edu/DOC/Middleware/trunk/TAO
........
r80955 | johnnyw | 2008-03-17 04:06:25 -0500 (Mon, 17 Mar 2008) | 1 line
Mon Mar 17 09:02:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
........
r80956 | johnnyw | 2008-03-17 04:06:54 -0500 (Mon, 17 Mar 2008) | 1 line
Mon Mar 17 09:02:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
........
r80958 | johnnyw | 2008-03-17 04:15:14 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80959 | johnnyw | 2008-03-17 04:15:50 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80960 | johnnyw | 2008-03-17 04:16:27 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80961 | johnnyw | 2008-03-17 04:16:48 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80962 | johnnyw | 2008-03-17 04:17:10 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80964 | johnnyw | 2008-03-17 04:32:15 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80965 | johnnyw | 2008-03-17 04:32:57 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80966 | johnnyw | 2008-03-17 04:33:39 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80967 | johnnyw | 2008-03-17 04:48:48 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80968 | johnnyw | 2008-03-17 04:59:51 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80969 | johnnyw | 2008-03-17 05:00:05 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80970 | johnnyw | 2008-03-17 05:01:53 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80971 | johnnyw | 2008-03-17 05:35:34 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80972 | johnnyw | 2008-03-17 05:44:11 -0500 (Mon, 17 Mar 2008) | 1 line
Mon Mar 17 10:42:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
........
r80973 | johnnyw | 2008-03-17 07:47:41 -0500 (Mon, 17 Mar 2008) | 1 line
........
r80974 | johnnyw | 2008-03-17 08:40:44 -0500 (Mon, 17 Mar 2008) | 1 line
Mon Mar 17 13:39:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
........
31 files changed, 1344 insertions, 117 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index a076bea6c24..11f7c45526b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,61 @@ +Mon Mar 17 13:39:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> + + * orbsvcs/orbsvcs/Notify/Builder.cpp: + * orbsvcs/orbsvcs/Notify/Builder.h: + Changed build_filter_factory to accept a POA_ptr instead + of retrieving it here + + * orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp: + Use CORBA::is_nil to check for a nil object reference + + * orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp: + * orbsvcs/orbsvcs/Notify/ETCL_Filter.h: + Store the POA used to activate the filter, use it then + when cleaning up + + * orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp: + * orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h: + * orbsvcs/orbsvcs/Notify/FilterFactory.h: + Don't use _this but the POA passed. Also changed the + signatures of some methods to get the regular memory + management + + * orbsvcs/orbsvcs/Notify/EventChannel.cpp: + * orbsvcs/orbsvcs/Notify/EventChannel.h: + Create a filter factory for each event channel instead + of a global singleton + + * orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp: + * orbsvcs/orbsvcs/Notify/EventChannelFactory.h: + Removed the global event filter factory + + * orbsvcs/orbsvcs/Notify/POA_Helper.cpp: + Layout changes + + * orbsvcs/tests/Notify/Bug_3252_Regression/server.cpp: + Use 5 load/unload iterations + + * orbsvcs/orbsvcs/IFRService/Repository_i.cpp: + Const change + +Mon Mar 17 10:42:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> + + * orbsvcs/tests/Notify/Bug_3252_Regression/Persistent_POA.{h,cpp}: + Removed + + * orbsvcstests/Notify/Bug_3252_Regression/Bug_3252_Regression.mpc: + Updated + +Mon Mar 17 09:02:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> + + * orbsvcs/tests/Notify/Bug_3252_Regression/*: + New test for bugzilla 3252 + +Mon Mar 17 09:02:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> + + * tests/Bug_3251_Regression/*: + New test for bugzilla 3251 + Fri Mar 14 14:59:57 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl> * tao/IOP.pidl: diff --git a/TAO/orbsvcs/orbsvcs/IFRService/Repository_i.cpp b/TAO/orbsvcs/orbsvcs/IFRService/Repository_i.cpp index 995534cce41..2614268b0b7 100644 --- a/TAO/orbsvcs/orbsvcs/IFRService/Repository_i.cpp +++ b/TAO/orbsvcs/orbsvcs/IFRService/Repository_i.cpp @@ -581,7 +581,7 @@ TAO_Repository_i::create_sections (void) 1, // It doesn't exist so create it. this->pkinds_key_); - u_int num_pkinds = this->num_pkinds (); + u_int const num_pkinds = this->num_pkinds (); for (u_int i = 0; i < num_pkinds; ++i) { diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp index d8079c6dcfa..712897a1756 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp @@ -166,7 +166,7 @@ TAO_Notify_Builder::~TAO_Notify_Builder () } CosNotifyFilter::FilterFactory_ptr -TAO_Notify_Builder::build_filter_factory (void) +TAO_Notify_Builder::build_filter_factory (PortableServer::POA_ptr poa) { TAO_Notify_FilterFactory* ff = ACE_Dynamic_Service<TAO_Notify_FilterFactory>::instance ("TAO_Notify_FilterFactory"); @@ -177,9 +177,7 @@ TAO_Notify_Builder::build_filter_factory (void) CORBA::NO_MEMORY ()); } - PortableServer::POA_var default_poa = TAO_Notify_PROPERTIES::instance ()->default_poa (); - - return ff->create (default_poa); + return ff->create (poa); } CosNotifyChannelAdmin::EventChannelFactory_ptr diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.h b/TAO/orbsvcs/orbsvcs/Notify/Builder.h index 1eba8f19066..6fe36a0234d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Builder.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.h @@ -60,8 +60,8 @@ public: , const char* factory_name = 0); /// Build the Filter Factory. - virtual CosNotifyFilter::FilterFactory_ptr build_filter_factory ( - ); + virtual CosNotifyFilter::FilterFactory_ptr + build_filter_factory (PortableServer::POA_ptr poa); /// Build EventChannel. virtual CosNotifyChannelAdmin::EventChannel_ptr @@ -71,7 +71,6 @@ public: , CosNotifyChannelAdmin::ChannelID_out id , const char* ec_name = 0); - virtual TAO_Notify_EventChannel * build_event_channel (TAO_Notify_EventChannelFactory* ecf , const CosNotifyChannelAdmin::ChannelID id @@ -143,21 +142,17 @@ public: build_proxy (TAO_Notify_SupplierAdmin* sa); /// Apply Reactive concurrency. - virtual void apply_reactive_concurrency ( - TAO_Notify_Object& object - ); + virtual void apply_reactive_concurrency (TAO_Notify_Object& object); /// Apply Thread Pools. virtual void apply_thread_pool_concurrency ( TAO_Notify_Object& object, - const NotifyExt::ThreadPoolParams& tp_params - ); + const NotifyExt::ThreadPoolParams& tp_params); /// Apply Thread Pools with Lanes. virtual void apply_lane_concurrency ( TAO_Notify_Object& object, - const NotifyExt::ThreadPoolLanesParams& tpl_params - ); + const NotifyExt::ThreadPoolLanesParams& tpl_params); }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp index 12d2ecb65ec..78ca7166d32 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/CosNotify_Service.cpp @@ -226,7 +226,7 @@ TAO_CosNotify_Service::init_service (CORBA::ORB_ptr orb) if (TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb()) { // got here by way of svc.conf. no second orb supplied so create one - if (0 == TAO_Notify_PROPERTIES::instance()->dispatching_orb()) + if (CORBA::is_nil (TAO_Notify_PROPERTIES::instance()->dispatching_orb())) { ACE_DEBUG ((LM_DEBUG, "No dispatching orb supplied. Creating default one.\n")); diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp index a6549b1eace..85caa64ae99 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp @@ -12,8 +12,9 @@ ACE_RCSID(Notify, TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO_Notify_ETCL_Filter::TAO_Notify_ETCL_Filter (void) - :constraint_expr_ids_ (0) +TAO_Notify_ETCL_Filter::TAO_Notify_ETCL_Filter (PortableServer::POA_ptr poa) + : constraint_expr_ids_ (0), + poa_ (PortableServer::POA::_duplicate (poa)) { } @@ -42,12 +43,12 @@ TAO_Notify_ETCL_Filter::constraint_grammar (void) } void -TAO_Notify_ETCL_Filter::add_constraints_i (const CosNotifyFilter::ConstraintInfoSeq& constraint_info_seq - ) +TAO_Notify_ETCL_Filter::add_constraints_i ( + const CosNotifyFilter::ConstraintInfoSeq& constraint_info_seq) { for (CORBA::ULong index = 0; index < constraint_info_seq.length (); ++index) { - TAO_Notify_Constraint_Expr* notify_constr_expr; + TAO_Notify_Constraint_Expr* notify_constr_expr = 0; ACE_NEW_THROW_EX (notify_constr_expr, TAO_Notify_Constraint_Expr (), @@ -75,8 +76,8 @@ TAO_Notify_ETCL_Filter::add_constraints_i (const CosNotifyFilter::ConstraintInfo } CosNotifyFilter::ConstraintInfoSeq* -TAO_Notify_ETCL_Filter::add_constraints (const CosNotifyFilter::ConstraintExpSeq& constraint_list - ) +TAO_Notify_ETCL_Filter::add_constraints ( + const CosNotifyFilter::ConstraintExpSeq& constraint_list) { ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); @@ -117,9 +118,9 @@ TAO_Notify_ETCL_Filter::add_constraints (const CosNotifyFilter::ConstraintExpSeq } void -TAO_Notify_ETCL_Filter::modify_constraints (const CosNotifyFilter::ConstraintIDSeq & del_list, - const CosNotifyFilter::ConstraintInfoSeq & modify_list - ) +TAO_Notify_ETCL_Filter::modify_constraints ( + const CosNotifyFilter::ConstraintIDSeq & del_list, + const CosNotifyFilter::ConstraintInfoSeq & modify_list) { ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); @@ -197,8 +198,8 @@ TAO_Notify_ETCL_Filter::modify_constraints (const CosNotifyFilter::ConstraintIDS } CosNotifyFilter::ConstraintInfoSeq* -TAO_Notify_ETCL_Filter::get_constraints (const CosNotifyFilter::ConstraintIDSeq & id_list - ) +TAO_Notify_ETCL_Filter::get_constraints ( + const CosNotifyFilter::ConstraintIDSeq & id_list) { ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); @@ -305,11 +306,9 @@ TAO_Notify_ETCL_Filter::destroy (void) this->remove_all_constraints_i (); - PortableServer::POA_var my_POA = _default_POA (); + PortableServer::ObjectId_var refTemp = poa_->servant_to_id (this); - PortableServer::ObjectId_var refTemp = my_POA->servant_to_id (this); - - my_POA->deactivate_object (refTemp.in ()); + poa_->deactivate_object (refTemp.in ()); } CORBA::Boolean @@ -319,8 +318,8 @@ TAO_Notify_ETCL_Filter::match (const CORBA::Any & /*filterable_data */) } CORBA::Boolean -TAO_Notify_ETCL_Filter::match_structured (const CosNotification::StructuredEvent & filterable_data - ) +TAO_Notify_ETCL_Filter::match_structured ( + const CosNotification::StructuredEvent & filterable_data) { ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); @@ -361,16 +360,14 @@ TAO_Notify_ETCL_Filter::match_typed ( CosNotifyFilter::CallbackID TAO_Notify_ETCL_Filter::attach_callback ( - CosNotifyComm::NotifySubscribe_ptr /* callback */ - ) + CosNotifyComm::NotifySubscribe_ptr /* callback */) { throw CORBA::NO_IMPLEMENT (); } void TAO_Notify_ETCL_Filter::detach_callback ( - CosNotifyFilter::CallbackID /* callback */ - ) + CosNotifyFilter::CallbackID /* callback */) { throw CORBA::NO_IMPLEMENT (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h index a5014412d7e..91305df0485 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h @@ -44,10 +44,10 @@ class TAO_Notify_Serv_Export TAO_Notify_ETCL_Filter { public: /// Constuctor - TAO_Notify_ETCL_Filter (void); + TAO_Notify_ETCL_Filter (PortableServer::POA_ptr poa); /// Destructor - virtual ~TAO_Notify_ETCL_Filter (); + virtual ~TAO_Notify_ETCL_Filter (void); protected: virtual char * constraint_grammar (void); @@ -108,6 +108,8 @@ private: CONSTRAINT_EXPR_LIST; CONSTRAINT_EXPR_LIST constraint_expr_list_; + + PortableServer::POA_var poa_; }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp index 1475f2b0851..2d2b79d9f26 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp @@ -8,7 +8,8 @@ ACE_RCSID(Notify, TAO_Notify_ETCL_FilterFactory, "$Id$") TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO_Notify_ETCL_FilterFactory::TAO_Notify_ETCL_FilterFactory (void) +TAO_Notify_ETCL_FilterFactory::TAO_Notify_ETCL_FilterFactory (void) : + filter_poa_ (PortableServer::POA::_nil ()) { } @@ -17,13 +18,19 @@ TAO_Notify_ETCL_FilterFactory::~TAO_Notify_ETCL_FilterFactory () } CosNotifyFilter::FilterFactory_ptr -TAO_Notify_ETCL_FilterFactory::create (PortableServer::POA_var& filter_poa) +TAO_Notify_ETCL_FilterFactory::create (PortableServer::POA_ptr filter_poa) { - this->filter_poa_ = filter_poa; // save the filter poa. + this->filter_poa_ = PortableServer::POA::_duplicate(filter_poa); // save the filter poa. PortableServer::ServantBase_var servant_var (this); - return _this (); + PortableServer::ObjectId_var id = filter_poa->activate_object (this); + + CORBA::Object_var object = filter_poa->id_to_reference (id.in ()); + + CosNotifyFilter::FilterFactory_var filter = CosNotifyFilter::FilterFactory::_narrow (object.in ()); + + return filter._retn(); } CosNotifyFilter::Filter_ptr @@ -35,12 +42,11 @@ TAO_Notify_ETCL_FilterFactory::create_filter (const char *constraint_grammar) ACE_OS::strcmp (constraint_grammar, "EXTENDED_TCL") != 0) throw CosNotifyFilter::InvalidGrammar (); - // Create the RefCounted servant. TAO_Notify_ETCL_Filter* filter = 0; ACE_NEW_THROW_EX (filter, - TAO_Notify_ETCL_Filter (), + TAO_Notify_ETCL_Filter (this->filter_poa_.in ()), CORBA::NO_MEMORY ()); PortableServer::ServantBase_var filter_var (filter); @@ -56,8 +62,7 @@ TAO_Notify_ETCL_FilterFactory::create_filter (const char *constraint_grammar) CosNotifyFilter::MappingFilter_ptr TAO_Notify_ETCL_FilterFactory::create_mapping_filter (const char * /*constraint_grammar*/, - const CORBA::Any & /*default_value*/ - ) + const CORBA::Any & /*default_value*/) { throw CORBA::NO_IMPLEMENT (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h index 55871ecd0ca..a7ad9f70063 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h @@ -51,19 +51,16 @@ public: ///= TAO_Notify_FilterFactory methods. virtual CosNotifyFilter::FilterFactory_ptr create ( - PortableServer::POA_var& filter_poa - ); + PortableServer::POA_ptr filter_poa); ///= CosNotifyFilter::FilterFactory methods virtual CosNotifyFilter::Filter_ptr create_filter ( - const char * constraint_grammar - ); + const char * constraint_grammar); virtual CosNotifyFilter::MappingFilter_ptr create_mapping_filter ( const char * constraint_grammar, - const CORBA::Any & default_value - ); + const CORBA::Any & default_value); protected: /// The POA in which to activate the Filters. diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp index 47f2c4fa838..2292e6ef782 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp @@ -47,6 +47,7 @@ TAO_Notify_EventChannel::TAO_Notify_EventChannel (void) : ecf_ (0) , ca_container_ (0) , sa_container_ (0) + , default_filter_factory_ (CosNotifyFilter::FilterFactory::_nil ()) { } @@ -109,6 +110,10 @@ TAO_Notify_EventChannel::init (TAO_Notify_EventChannelFactory* ecf this->set_admin (initial_admin); + PortableServer::POA_var default_poa = TAO_Notify_PROPERTIES::instance ()->default_poa (); + this->default_filter_factory_ = + TAO_Notify_PROPERTIES::instance()->builder()->build_filter_factory (default_poa.in()); + // Note originally default admins were allocated here, bt this caused problems // attempting to save the topology changes before the Event Channel was completely // constructed and linked to the ECF. @@ -165,6 +170,9 @@ TAO_Notify_EventChannel::init (TAO_Notify::Topology_Parent* parent) this->set_qos (default_ec_qos); + PortableServer::POA_var default_poa = TAO_Notify_PROPERTIES::instance ()->default_poa (); + this->default_filter_factory_ = + TAO_Notify_PROPERTIES::instance()->builder()->build_filter_factory (default_poa.in ()); } @@ -188,8 +196,7 @@ TAO_Notify_EventChannel::release (void) } void -TAO_Notify_EventChannel::cleanup_proxy (CosNotifyChannelAdmin::ProxyID - , bool ) +TAO_Notify_EventChannel::cleanup_proxy (CosNotifyChannelAdmin::ProxyID, bool) { } int @@ -214,8 +221,7 @@ TAO_Notify_EventChannel::destroy (void) { TAO_Notify_EventChannel::Ptr guard( this ); - int result = this->shutdown (); - if ( result == 1) + if (this->shutdown () == 1) return; this->ecf_->remove (this); @@ -225,6 +231,8 @@ TAO_Notify_EventChannel::destroy (void) this->sa_container_.reset( 0 ); this->ca_container_.reset( 0 ); + + this->default_filter_factory_ = CosNotifyFilter::FilterFactory::_nil(); } void @@ -306,16 +314,15 @@ TAO_Notify_EventChannel::default_supplier_admin (void) return CosNotifyChannelAdmin::SupplierAdmin::_duplicate (this->default_supplier_admin_.in ()); } -::CosNotifyFilter::FilterFactory_ptr TAO_Notify_EventChannel::default_filter_factory (void) +::CosNotifyFilter::FilterFactory_ptr +TAO_Notify_EventChannel::default_filter_factory (void) { - return this->ecf_->get_default_filter_factory (); + return CosNotifyFilter::FilterFactory::_duplicate (this->default_filter_factory_.in ()); } ::CosNotifyChannelAdmin::ConsumerAdmin_ptr TAO_Notify_EventChannel::new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupOperator op, - CosNotifyChannelAdmin::AdminID_out id - ) - + CosNotifyChannelAdmin::AdminID_out id) { ::CosNotifyChannelAdmin::ConsumerAdmin_var ca = TAO_Notify_PROPERTIES::instance()->builder()->build_consumer_admin (this, op, id); @@ -325,8 +332,7 @@ TAO_Notify_EventChannel::new_for_consumers (CosNotifyChannelAdmin::InterFilterGr ::CosNotifyChannelAdmin::SupplierAdmin_ptr TAO_Notify_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, - CosNotifyChannelAdmin::AdminID_out id - ) + CosNotifyChannelAdmin::AdminID_out id) { ::CosNotifyChannelAdmin::SupplierAdmin_var sa = TAO_Notify_PROPERTIES::instance()->builder()->build_supplier_admin (this, op, id); @@ -400,8 +406,7 @@ TAO_Notify_EventChannel::for_suppliers (void) void TAO_Notify_EventChannel::validate_qos (const CosNotification::QoSProperties & /*required_qos*/, - CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ - ) + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/) { throw CORBA::NO_IMPLEMENT (); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h index 522867bda64..9adc95ec755 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h @@ -177,6 +177,9 @@ private: /// SupplierAdmin Container. ACE_Auto_Ptr< TAO_Notify_SupplierAdmin_Container > sa_container_; + /// The default filter factory. + CosNotifyFilter::FilterFactory_var default_filter_factory_; + /// Release virtual void release (void); }; diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp index 182464a9b39..d958167541c 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp @@ -2,7 +2,9 @@ #include "orbsvcs/Notify/EventChannelFactory.h" -ACE_RCSID(Notify, TAO_Notify_EventChannelFactory, "$Id$") +ACE_RCSID(Notify, + TAO_Notify_EventChannelFactory, + "$Id$") #include "orbsvcs/Notify/Properties.h" #include "orbsvcs/Notify/Factory.h" @@ -62,8 +64,7 @@ TAO_Notify_EventChannelFactory::~TAO_Notify_EventChannelFactory () void TAO_Notify_EventChannelFactory::destroy (void) { - int result = this->shutdown (); - if ( result == 1) + if (this->shutdown () == 1) return; TAO_Notify_Properties* properties = TAO_Notify_PROPERTIES::instance(); @@ -80,9 +81,6 @@ TAO_Notify_EventChannelFactory::init (PortableServer::POA_ptr poa) { ACE_ASSERT (this->ec_container_.get() == 0); - this->default_filter_factory_ = - TAO_Notify_PROPERTIES::instance()->builder()->build_filter_factory (); - // Init ec_container_ TAO_Notify_EventChannel_Container* ecc = 0; ACE_NEW_THROW_EX (ecc, @@ -149,9 +147,7 @@ TAO_Notify_EventChannelFactory::remove (TAO_Notify_EventChannel* event_channel) int TAO_Notify_EventChannelFactory::shutdown (void) { - int sd_ret = TAO_Notify_Object::shutdown (); - - if (sd_ret == 1) + if (TAO_Notify_Object::shutdown () == 1) return 1; this->ec_container().shutdown (); @@ -159,12 +155,6 @@ TAO_Notify_EventChannelFactory::shutdown (void) return 0; } -CosNotifyFilter::FilterFactory_ptr -TAO_Notify_EventChannelFactory::get_default_filter_factory (void) -{ - return CosNotifyFilter::FilterFactory::_duplicate (this->default_filter_factory_.in ()); -} - CosNotifyChannelAdmin::EventChannel_ptr TAO_Notify_EventChannelFactory::create_named_channel ( const CosNotification::QoSProperties& initial_qos, diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h index d6ee6fc6b8e..eeb6f245191 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h @@ -68,13 +68,9 @@ public: virtual void _add_ref (void); virtual void _remove_ref (void); - /// Remove <channel> from the <ec_container_> + /// Remove @a channel from the <ec_container_> virtual void remove (TAO_Notify_EventChannel* channel); - /// Accesor for the default filter factory shared by all EC's. - virtual CosNotifyFilter::FilterFactory_ptr get_default_filter_factory ( - ); - /// This method is called by the Notify_Service when the event channel /// is automatically created and bound in the name service. virtual CosNotifyChannelAdmin::EventChannel_ptr create_named_channel ( @@ -98,7 +94,7 @@ public: //-- Topology_Parent - virtual bool is_persistent () const; + virtual bool is_persistent (void) const; virtual void save_persistent (TAO_Notify::Topology_Saver& saver); virtual bool change_to_parent (void); @@ -118,16 +114,12 @@ public: TAO_Notify_ProxyConsumer * find_proxy_consumer (TAO_Notify::IdVec & id_path, size_t position); TAO_Notify_ProxySupplier * find_proxy_supplier (TAO_Notify::IdVec & id_path, size_t position); TAO_Notify_Object * follow_id_path (TAO_Notify::IdVec & id_path, size_t position); - virtual TAO_Notify_Object::ID get_id () const; - + virtual TAO_Notify_Object::ID get_id (void) const; private: /// = Data Members - /// The default filter factory. - CosNotifyFilter::FilterFactory_var default_filter_factory_; - /// = NotifyExt methods virtual void destroy (void); @@ -148,15 +140,12 @@ protected: virtual ::CosNotifyChannelAdmin::EventChannel_ptr create_channel ( const CosNotification::QoSProperties & initial_qos, const CosNotification::AdminProperties & initial_admin, - CosNotifyChannelAdmin::ChannelID_out id - ); + CosNotifyChannelAdmin::ChannelID_out id); - virtual ::CosNotifyChannelAdmin::ChannelIDSeq * get_all_channels ( - ); + virtual ::CosNotifyChannelAdmin::ChannelIDSeq * get_all_channels (void); virtual ::CosNotifyChannelAdmin::EventChannel_ptr get_event_channel ( - CosNotifyChannelAdmin::ChannelID id - ); + CosNotifyChannelAdmin::ChannelID id); private: typedef TAO_Notify_Container_T<TAO_Notify_EventChannel> TAO_Notify_EventChannel_Container; diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h index bc8e6a4e164..1e0b3c56895 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h @@ -38,7 +38,7 @@ public: /// Factory method to create a FilterFactory reference /// The Factory is activated in the default POA. The filters created are activated in the <filter_poa>. virtual CosNotifyFilter::FilterFactory_ptr create ( - PortableServer::POA_var& filter_poa) = 0; + PortableServer::POA_ptr filter_poa) = 0; }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp index 9535a47a99c..d6926c6f8e4 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp @@ -20,7 +20,7 @@ TAO_Notify_POA_Helper::TAO_Notify_POA_Helper (void) { } -TAO_Notify_POA_Helper::~TAO_Notify_POA_Helper () +TAO_Notify_POA_Helper::~TAO_Notify_POA_Helper (void) { } @@ -95,15 +95,16 @@ TAO_Notify_POA_Helper::set_persistent_policy (PortableServer::POA_ptr parent_poa void -TAO_Notify_POA_Helper::create_i (PortableServer::POA_ptr parent_poa, const char* poa_name, CORBA::PolicyList &policy_list) +TAO_Notify_POA_Helper::create_i ( + PortableServer::POA_ptr parent_poa, + const char* poa_name, + CORBA::PolicyList &policy_list) { PortableServer::POAManager_var manager = parent_poa->the_POAManager (); // Create the child POA. - this->poa_ = parent_poa->create_POA (poa_name, - manager.in (), - policy_list); + this->poa_ = parent_poa->create_POA (poa_name, manager.in (), policy_list); if (DEBUG_LEVEL > 0) { @@ -164,11 +165,9 @@ TAO_Notify_POA_Helper::activate (PortableServer::Servant servant, CORBA::Long& i } // Convert CORBA::Long to ObjectId - PortableServer::ObjectId_var oid = - this->long_to_ObjectId (id); + PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); - poa_->activate_object_with_id (oid.in (), - servant); + poa_->activate_object_with_id (oid.in (), servant); return poa_->id_to_reference (oid.in ()); } @@ -184,11 +183,9 @@ TAO_Notify_POA_Helper::activate_with_id (PortableServer::Servant servant, CORBA: this->id_factory_.set_last_used (id); // Convert CORBA::Long to ObjectId - PortableServer::ObjectId_var oid = - this->long_to_ObjectId (id); + PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); - poa_->activate_object_with_id (oid.in (), - servant); + poa_->activate_object_with_id (oid.in (), servant); return poa_->id_to_reference (oid.in ()); } @@ -197,8 +194,7 @@ void TAO_Notify_POA_Helper::deactivate (CORBA::Long id) const { // Convert CORBA::Long to ObjectId - PortableServer::ObjectId_var oid = - this->long_to_ObjectId (id); + PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); poa_->deactivate_object (oid.in ()); } @@ -207,8 +203,7 @@ CORBA::Object_ptr TAO_Notify_POA_Helper::id_to_reference (CORBA::Long id) const { // Convert CORBA::Long to ObjectId - PortableServer::ObjectId_var oid = - this->long_to_ObjectId (id); + PortableServer::ObjectId_var oid = this->long_to_ObjectId (id); return poa_->id_to_reference (oid.in ()); } diff --git a/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/Bug_3252_Regression.mpc b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/Bug_3252_Regression.mpc new file mode 100644 index 00000000000..2e5ad24c5b9 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/Bug_3252_Regression.mpc @@ -0,0 +1,17 @@ +// $Id$ + +project(*server): notification_serv, taoexe { + exename=server + libs += Bug_3252 + Source_Files { + server.cpp + } +} + +project: portableserver { + sharedname = Bug_3252 + dynamicflags += BUG_3252_REGRESSION_BUILD_DLL + Source_Files { + DllOrb.cpp + } +} diff --git a/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.cpp b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.cpp new file mode 100644 index 00000000000..a636fe562c2 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.cpp @@ -0,0 +1,176 @@ +// $Id$ + +#include "DllOrb.h" +#include "ace/Arg_Shifter.h" +#include "ace/Argv_Type_Converter.h" +#include "ace/OS_NS_unistd.h" +#include "tao/TAO_Singleton_Manager.h" + + +DllOrb::DllOrb (void) + : + ma_barrier_(), + mv_orb_ (), + mv_rootPOA_ () +{ +} + + +DllOrb::~DllOrb (void) +{ +} + + +int +DllOrb::init (int argc, ACE_TCHAR *argv[]) +{ + int threadCnt = 1; + + try + { + ACE_Arg_Shifter as (argc, argv); + const ACE_TCHAR *currentArg = 0; + while (as.is_anything_left ()) + { + if (0 != (currentArg = as.get_the_parameter (ACE_TEXT ("-NumThreads")))) + { + int num = ACE_OS::atoi (currentArg); + if (num >= 1) + threadCnt = num; + as.consume_arg (); + } + else + as.ignore_arg (); + } + + // Initialize the ORB + ACE_Argv_Type_Converter argcon (argc, argv); + mv_orb_ = CORBA::ORB_init (argcon.get_argc (), argcon.get_ASCII_argv ()); + if (CORBA::is_nil (mv_orb_.in ())) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil ORB\n"))); + return -1; + } + + CORBA::Object_var v_poa = + mv_orb_->resolve_initial_references ("RootPOA"); + + mv_rootPOA_ = PortableServer::POA::_narrow (v_poa.in ()); + if (CORBA::is_nil (mv_rootPOA_.in ())) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil RootPOA\n"))); + return -1; + } + + mv_poaManager_ = mv_rootPOA_->the_POAManager (); + if (CORBA::is_nil (mv_poaManager_.in ())) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil POAManager\n"))); + return -1; + } + + mv_poaManager_->activate (); + } + catch (...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n"))); + return -1; + } + + ma_barrier_ = auto_ptr < ACE_Thread_Barrier >( + new ACE_Thread_Barrier(threadCnt + 1) + ); + + this->activate( + THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, + threadCnt + ); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("init mp_barrier->wait() ...\n"))); + ma_barrier_->wait(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("init mp_barrier->wait() done\n"))); + + return 0; +} + + +int +DllOrb::fini (void) +{ + try + { + mv_poaManager_->deactivate (1, 1); + mv_poaManager_ = PortableServer::POAManager::_nil (); + + // attempt to protect against sporadic BAD_INV_ORDER exceptions + ACE_OS::sleep (ACE_Time_Value (0, 500)); + + mv_orb_->shutdown (1); + + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("wait() ...\n"))); + // wait for our threads to finish + wait(); + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("wait() done\n"))); + + ma_barrier_.reset(); + } + catch (...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n"))); + return -1; + } + + try + { + mv_orb_->destroy (); + mv_orb_ = CORBA::ORB::_nil (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return -1; + } + + return 0; +} + + +int DllOrb::svc (void) +{ + ACE_DEBUG ((LM_INFO, ACE_TEXT ("svc mp_barrier->wait() ...\n"))); + ma_barrier_->wait(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("svc mp_barrier->wait() done\n"))); + + try + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("mv_orb->run ...\n"))); + try + { + mv_orb_->run(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("mv_orb->run returned\n"))); + } + catch(CORBA::BAD_INV_ORDER const & rc_ex) + { + const CORBA::ULong VMCID = rc_ex.minor() & 0xFFFFF000U; + const CORBA::ULong minorCode = rc_ex.minor() & 0xFFFU; + if (VMCID == CORBA::OMGVMCID && minorCode == 4) + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("ignored 'CORBA::BAD_INV_ORDER: ORB has shutdown.'\n"))); + } + else + { + throw; + } + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("mv_orb->run done\n"))); + } + catch(...) + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Exception\n"))); + return -1; + } + + return 0; +} /* end of DllOrb::svc ( ) */ + + +ACE_FACTORY_DEFINE (bug_3252, DllOrb) diff --git a/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.h b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.h new file mode 100644 index 00000000000..7a307a12eca --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/DllOrb.h @@ -0,0 +1,38 @@ +// $Id$ + +#ifndef bug_3252_DllORB_h +#define bug_3252_DllORB_h + +#include "ace/Barrier.h" +#include "ace/Task.h" +#include "ace/Auto_Ptr.h" +#include "tao/ORB.h" + +#include "tao/PortableServer/PortableServer.h" +#include "bug_3252_export.h" + + +class bug_3252_Export DllOrb: public ACE_Task_Base +{ +public: + DllOrb (void); + virtual ~DllOrb (void); + + CORBA::ORB_ptr orb (void) const { return CORBA::ORB::_duplicate(mv_orb_.in()); } + + virtual int init (int argc, ACE_TCHAR *argv[]); + + virtual int fini (void); + + virtual int svc (void); + +private: + auto_ptr < ACE_Thread_Barrier > ma_barrier_; + CORBA::ORB_var mv_orb_; + PortableServer::POA_var mv_rootPOA_; + PortableServer::POAManager_var mv_poaManager_; +}; + +ACE_FACTORY_DECLARE (bug_3252, DllOrb) + +#endif /* bug_3252_DllORB_h */ diff --git a/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/bug_3252_export.h b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/bug_3252_export.h new file mode 100644 index 00000000000..b9ec40223b0 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/bug_3252_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl bug_3252 +// ------------------------------ +#ifndef BUG_3252_REGRESSION_EXPORT_H +#define BUG_3252_REGRESSION_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BUG_3252_REGRESSION_HAS_DLL) +# define BUG_3252_REGRESSION_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BUG_3252_REGRESSION_HAS_DLL */ + +#if !defined (BUG_3252_REGRESSION_HAS_DLL) +# define BUG_3252_REGRESSION_HAS_DLL 1 +#endif /* ! BUG_3252_REGRESSION_HAS_DLL */ + +#if defined (BUG_3252_REGRESSION_HAS_DLL) && (BUG_3252_REGRESSION_HAS_DLL == 1) +# if defined (BUG_3252_REGRESSION_BUILD_DLL) +# define bug_3252_Export ACE_Proper_Export_Flag +# define BUG_3252_REGRESSION_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BUG_3252_REGRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BUG_3252_REGRESSION_BUILD_DLL */ +# define bug_3252_Export ACE_Proper_Import_Flag +# define BUG_3252_REGRESSION_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BUG_3252_REGRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BUG_3252_REGRESSION_BUILD_DLL */ +#else /* BUG_3252_REGRESSION_HAS_DLL == 1 */ +# define bug_3252_Export +# define BUG_3252_REGRESSION_SINGLETON_DECLARATION(T) +# define BUG_3252_REGRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BUG_3252_REGRESSION_HAS_DLL == 1 */ + +// Set BUG_3252_REGRESSION_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BUG_3252_REGRESSION_NTRACE) +# if (ACE_NTRACE == 1) +# define BUG_3252_REGRESSION_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BUG_3252_REGRESSION_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BUG_3252_REGRESSION_NTRACE */ + +#if (BUG_3252_REGRESSION_NTRACE == 1) +# define BUG_3252_REGRESSION_TRACE(X) +#else /* (BUG_3252_REGRESSION_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BUG_3252_REGRESSION_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BUG_3252_REGRESSION_NTRACE == 1) */ + +#endif /* BUG_3252_REGRESSION_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/run_test.pl b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/run_test.pl new file mode 100755 index 00000000000..bacca8c802f --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/run_test.pl @@ -0,0 +1,31 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::Run_Test; + +if (PerlACE::is_vxworks_test()) { + $SVP = new PerlACE::ProcessVX ("server", ""); +} +else { + $SVP = new PerlACE::Process ("server", ""); +} +# Run the AMH server. +$sv = $SVP->Spawn (); + +if ($sv != 0) { + print STDERR "ERROR: server returned $sv\n"; + exit 1; +} + +$svnk = $SVP->WaitKill (60); +if ($svnk != 0) { + print STDERR "ERROR: Server returned $svnk\n"; + $status = 1; +} + +exit $status; diff --git a/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/server.cpp b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/server.cpp new file mode 100644 index 00000000000..d2b42f59355 --- /dev/null +++ b/TAO/orbsvcs/tests/Notify/Bug_3252_Regression/server.cpp @@ -0,0 +1,237 @@ +// $Id$ + +#include "ace/ARGV.h" +#include "ace/OS.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" + +#include "tao/corba.h" +#include "tao/ORB.h" +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/CosNotifyChannelAdminC.h" +#include "orbsvcs/Notify/CosNotify_Service.h" + +#include "DllOrb.h" + +char const * const scpc_loadOrb = ACE_DYNAMIC_SERVICE_DIRECTIVE( + "testDllOrb", + "Bug_3252", + "_make_DllOrb", + "testDllOrb -ORBDebugLevel 0 -ORBId testDllOrb -NumThreads 2 " + "-ORBDottedDecimalAddresses 1 -ORBCollocationStrategy thru_poa" +); + +char const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE("testDllOrb"); + +char const * const scpc_loadNotifyService = ACE_DYNAMIC_SERVICE_DIRECTIVE( + "testNotifyService", + "TAO_CosNotification_Serv", + "_make_TAO_CosNotify_Service", + "-UseSeparateDispatchingORB 1" +); + +char const * const scpc_unloadNotifyService = ACE_REMOVE_SERVICE_DIRECTIVE("testNotifyService"); + + +int unloadNotify(ACE_Service_Config & r_serviceConfig) +{ + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Unloading NotifyService ...\n"))); + int result = r_serviceConfig.process_directive(scpc_unloadNotifyService); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Unloading NotifyService failed\n"))); + return -1; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloading NotifyService done.\n"))); + return 0; +} + +int loadNotify(ACE_Service_Config & r_serviceConfig) +{ + int result = 0; + try + { + DllOrb * p_orb = ACE_Dynamic_Service<DllOrb>::instance ("testDllOrb"); + CORBA::ORB_var v_orb = p_orb->orb(); + + CORBA::Object_var v_poa = v_orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var v_rootPOA = PortableServer::POA::_narrow(v_poa.in ()); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("RootPOA OK.\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading NotifyService ...\n"))); + result = r_serviceConfig.process_directive(scpc_loadNotifyService); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Loading NotifyService failed\n"))); + return -1; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading NotifyService done.\n"))); + + TAO_CosNotify_Service * p_notifyService = + ACE_Dynamic_Service<TAO_CosNotify_Service>::instance("testNotifyService"); + + p_notifyService->init_service(v_orb.in()); + + CosNotifyChannelAdmin::EventChannelFactory_var v_notifyFactory = + p_notifyService->create( + v_rootPOA.in() + ); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("got EventChannelFactory\n"))); + + // create an event channel + CosNotifyChannelAdmin::ChannelID id; + + CosNotification::QoSProperties initialQos; + CosNotification::AdminProperties initialAdmin; + + CosNotifyChannelAdmin::EventChannel_var v_eventChannel = + v_notifyFactory->create_channel( + initialQos, + initialAdmin, + id + ); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("got EventChannel\n"))); + + CosNotifyFilter::FilterFactory_var v_filterFactory = + v_eventChannel->default_filter_factory(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("got FilterFactory\n"))); + + CosNotifyFilter::Filter_var v_filter = + v_filterFactory->create_filter("ETCL"); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("got Filter\n"))); + } + catch(CORBA::Exception const & rc_ex) + { + ACE_PRINT_TAO_EXCEPTION(rc_ex, "Unexpected CORBA Exception: "); + return -1; + } + catch(...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Unexpected C++ Exception\n"))); + return -1; + } + + return 0; +} + + +int unloadOrb(ACE_Service_Config & r_serviceConfig) +{ + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Unloading ORB ...\n"))); + int result = r_serviceConfig.process_directive(scpc_unloadOrb); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Unloading ORB failed\n"))); + return -1; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloading ORB done.\n"))); + return 0; +} + +int loadOrb(ACE_Service_Config & r_serviceConfig) +{ + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading ORB ...\n"))); + int result = r_serviceConfig.process_directive(scpc_loadOrb); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("Loading ORB failed\n"))); + return -1; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Loading ORB done.\n"))); + return 0; +} + + + +int +ACE_TMAIN(int, ACE_TCHAR ** argv) +{ + int result = 0; + + ACE_Service_Config serviceConfig; + + char signum[64]; + ACE_OS::sprintf(signum, "%d", SIGUSR1); + + ACE_ARGV args; + args.add(argv[0]); + args.add("-s"); + args.add(signum); + + result = serviceConfig.open ( + args.argc(), + args.argv(), + ACE_DEFAULT_LOGGER_KEY, + 1, // ignore_static_svcs = 1, + 1, // ignore_default_svc_conf_file = 0, + 0 // ignore_debug_flag = 0 + ); + + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("serviceConfig.open failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.open done\n"))); + + for(int i = 0; i < 5; ++i) + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadOrb ...\n"))); + result = loadOrb(serviceConfig); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("loadOrb failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadOrb done\n"))); + + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadNotify ...\n"))); + result = loadNotify(serviceConfig); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("loadNotify failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("loadNotify done\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadNotify ...\n"))); + result = unloadNotify(serviceConfig); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("unloadNotify failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadNotify done\n"))); + + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadOrb ...\n"))); + result = unloadOrb(serviceConfig); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("unloadOrb failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("unloadOrb done\n"))); + } + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs ...\n"))); + result = serviceConfig.fini_svcs(); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("serviceConfig.fini_svcs failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs done\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close ...\n"))); + result = serviceConfig.close(); + if(0 != result) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("serviceConfig.close failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close done\n"))); + + return 0; +} diff --git a/TAO/tests/Bug_3251_Regression/Bug_3251.conf b/TAO/tests/Bug_3251_Regression/Bug_3251.conf new file mode 100644 index 00000000000..5f0ce74d685 --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/Bug_3251.conf @@ -0,0 +1,3 @@ +dynamic PersistentPOA Service_Object * Bug_3251:_make_DllOrb() "DllOrb -NumThreads 12 -ORBDottedDecimalAddresses 1 -ORBCollocationStrategy thru_poa" +dynamic PersistentPOA Service_Object * Bug_3251:_make_PersistentPoa() "PersistentPOA DllOrb" + diff --git a/TAO/tests/Bug_3251_Regression/Bug_3251.conf.xml b/TAO/tests/Bug_3251_Regression/Bug_3251.conf.xml new file mode 100644 index 00000000000..95a3df2a37f --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/Bug_3251.conf.xml @@ -0,0 +1,30 @@ +<?xml version='1.0'?> +<ACE_Svc_Conf> + <!-- ACE will locate the libraries for you automatically by reading your LD --> + <!-- search path. Moreover, ACE will automatically insert the correct suffix --> + <!-- (e.g., ".dll", ".so", etc.). --> + + + <!-- ORB --> + <dynamic id="DllOrb" type="Service_Object"> + <!-- specify TS_ORB_ENDPOINT like this + TS_ORB_ENDPOINT="-ORBEndpoint iiop://aaa.bbb.ccc.ddd:nnnn" + + examples: + TS_ORB_ENDPOINT"-ORBEndpoint iiop://127.0.0.0" + TS_ORB_ENDPOINT"-ORBEndpoint iiop://:4200" + TS_ORB_ENDPOINT"-ORBEndpoint iiop://127.0.0.0:4200" + --> + <initializer path="Bug_3251" init="_make_DllOrb" params="DllOrb -NumThreads 12 -ORBDebugLevel $TS_ORB_DEBUGLEVEL $TS_ORB_ENDPOINT -ORBDottedDecimalAddresses 1 -ORBCollocationStrategy thru_poa"/> + </dynamic> + <!-- ORB --> + + + <!-- persistent POA --> + <dynamic id="PersistentPOA" type="Service_Object"> + <initializer path="Bug_3251" init="_make_PersistentPoa" params="PersistentPOA DllOrb"/> + </dynamic> + <!-- persistent POA --> + + +</ACE_Svc_Conf> diff --git a/TAO/tests/Bug_3251_Regression/Bug_3251_Regression.mpc b/TAO/tests/Bug_3251_Regression/Bug_3251_Regression.mpc new file mode 100644 index 00000000000..3f28ba17200 --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/Bug_3251_Regression.mpc @@ -0,0 +1,18 @@ +// $Id$ + +project(*server) : taoserver { + after += *lib + Source_Files { + server.cpp + } +} + +project(*lib): taolib, portableserver { + libout = . + sharedname = Bug_3251 + dynamicflags += BUG_3251_BUILD_DLL + Source_Files { + DllOrb.cpp + PersistentPoa.cpp + } +} diff --git a/TAO/tests/Bug_3251_Regression/DllOrb.cpp b/TAO/tests/Bug_3251_Regression/DllOrb.cpp new file mode 100644 index 00000000000..8303370d3c5 --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/DllOrb.cpp @@ -0,0 +1,176 @@ +// $Id$ + +#include "DllOrb.h" +#include "ace/Arg_Shifter.h" +#include "ace/Argv_Type_Converter.h" +#include "ace/OS_NS_unistd.h" +#include "tao/TAO_Singleton_Manager.h" + + +DllOrb::DllOrb (void) + : + ma_barrier_(), + mv_orb_ (), + mv_rootPOA_ () +{ +} + + +DllOrb::~DllOrb (void) +{ +} + + +int +DllOrb::init (int argc, ACE_TCHAR *argv[]) +{ + int threadCnt = 1; + + try + { + ACE_Arg_Shifter as (argc, argv); + const ACE_TCHAR *currentArg = 0; + while (as.is_anything_left ()) + { + if (0 != (currentArg = as.get_the_parameter (ACE_TEXT ("-NumThreads")))) + { + int num = ACE_OS::atoi (currentArg); + if (num >= 1) + threadCnt = num; + as.consume_arg (); + } + else + as.ignore_arg (); + } + + // Initialize the ORB + ACE_Argv_Type_Converter argcon (argc, argv); + mv_orb_ = CORBA::ORB_init (argcon.get_argc (), argcon.get_ASCII_argv ()); + if (CORBA::is_nil (mv_orb_.in ())) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil ORB\n"))); + return -1; + } + + CORBA::Object_var v_poa = + mv_orb_->resolve_initial_references ("RootPOA"); + + mv_rootPOA_ = PortableServer::POA::_narrow (v_poa.in ()); + if (CORBA::is_nil (mv_rootPOA_.in ())) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil RootPOA\n"))); + return -1; + } + + mv_poaManager_ = mv_rootPOA_->the_POAManager (); + if (CORBA::is_nil (mv_poaManager_.in ())) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("nil POAManager\n"))); + return -1; + } + + mv_poaManager_->activate (); + } + catch (...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n"))); + return -1; + } + + ma_barrier_ = std::auto_ptr < ACE_Thread_Barrier >( + new ACE_Thread_Barrier(threadCnt + 1) + ); + + this->activate( + THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, + threadCnt + ); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("init mp_barrier->wait() ...\n"))); + ma_barrier_->wait(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("init mp_barrier->wait() done\n"))); + + return 0; +} + + +int +DllOrb::fini (void) +{ + try + { + mv_poaManager_->deactivate (1, 1); + mv_poaManager_ = PortableServer::POAManager::_nil (); + + // attempt to protect against sporadic BAD_INV_ORDER exceptions + ACE_OS::sleep (ACE_Time_Value (0, 500)); + + mv_orb_->shutdown (1); + + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("wait() ...\n"))); + // wait for our threads to finish + wait(); + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("wait() done\n"))); + + ma_barrier_.reset(); + } + catch (...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("ERROR: exception\n"))); + return -1; + } + + try + { + mv_orb_->destroy (); + mv_orb_ = CORBA::ORB::_nil (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return -1; + } + + return 0; +} + + +int DllOrb::svc (void) +{ + ACE_DEBUG ((LM_INFO, ACE_TEXT ("svc mp_barrier->wait() ...\n"))); + ma_barrier_->wait(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("svc mp_barrier->wait() done\n"))); + + try + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("mv_orb->run ...\n"))); + try + { + mv_orb_->run(); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("mv_orb->run returned\n"))); + } + catch(CORBA::BAD_INV_ORDER const & rc_ex) + { + const CORBA::ULong VMCID = rc_ex.minor() & 0xFFFFF000U; + const CORBA::ULong minorCode = rc_ex.minor() & 0xFFFU; + if (VMCID == CORBA::OMGVMCID && minorCode == 4) + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("ignored 'CORBA::BAD_INV_ORDER: ORB has shutdown.'\n"))); + } + else + { + throw; + } + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("mv_orb->run done\n"))); + } + catch(...) + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Exception\n"))); + return -1; + } + + return 0; +} /* end of DllOrb::svc ( ) */ + + +ACE_FACTORY_DEFINE (bug_3251, DllOrb) diff --git a/TAO/tests/Bug_3251_Regression/DllOrb.h b/TAO/tests/Bug_3251_Regression/DllOrb.h new file mode 100644 index 00000000000..f8fe24bfba8 --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/DllOrb.h @@ -0,0 +1,38 @@ +// $Id$ + +#ifndef bug_3251_DllORB_h +#define bug_3251_DllORB_h + +#include "ace/Auto_Ptr.h" +#include "ace/Barrier.h" +#include "ace/Task.h" +#include "tao/ORB.h" + +#include "tao/PortableServer/PortableServer.h" +#include "bug_3251_export.h" + + +class bug_3251_Export DllOrb: public ACE_Task_Base +{ +public: + DllOrb (void); + virtual ~DllOrb (void); + + CORBA::ORB_ptr orb (void) const { return CORBA::ORB::_duplicate(mv_orb_.in()); } + + virtual int init (int argc, ACE_TCHAR *argv[]); + + virtual int fini (void); + + virtual int svc (void); + +private: + auto_ptr < ACE_Thread_Barrier > ma_barrier_; + CORBA::ORB_var mv_orb_; + PortableServer::POA_var mv_rootPOA_; + PortableServer::POAManager_var mv_poaManager_; +}; + +ACE_FACTORY_DECLARE (bug_3251, DllOrb) + +#endif /* bug_3251_DllORB_h */ diff --git a/TAO/tests/Bug_3251_Regression/PersistentPoa.cpp b/TAO/tests/Bug_3251_Regression/PersistentPoa.cpp new file mode 100644 index 00000000000..8ad9e5f23cc --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/PersistentPoa.cpp @@ -0,0 +1,104 @@ +// $Id$ + +#include "ace/Arg_Shifter.h" +#include "tao/PortableServer/POAManager.h" +#include "tao/PortableServer/PortableServer.h" + +#include "PersistentPoa.h" + +PersistentPoa::PersistentPoa ( ) +{ +} /* end of PersistentPoa::PersistentPoa ( ) */ + + +PersistentPoa::~PersistentPoa ( ) + throw () +{ +} /* end of PersistentPoa::~PersistentPoa ( ) */ + + +int PersistentPoa::init (int argc, char *argv[]) +{ + ACE_Arg_Shifter as(argc, argv); + m_poaName = std::string(as.get_current()); + as.ignore_arg(); + + std::string orbName(as.get_current()); + as.ignore_arg(); + + while(as.is_anything_left()) + { + as.ignore_arg(); + } + + try + { + // left out all safety checks + DllOrb * p_orb = ACE_Dynamic_Service<DllOrb>::instance (orbName.c_str()); + mv_orb = p_orb->orb(); + CORBA::Object_var v_poa = mv_orb->resolve_initial_references("RootPOA"); + mv_rootPOA = PortableServer::POA::_narrow(v_poa.in ()); + + // Threading policy + CORBA::Policy_var v_threadingPolicy = + mv_rootPOA->create_thread_policy(PortableServer::ORB_CTRL_MODEL); + + // Lifespan policy + CORBA::Policy_var v_lifespanPolicy = + mv_rootPOA->create_lifespan_policy(PortableServer::PERSISTENT); + + // ID assignment policy + CORBA::Policy_var v_idAssignmentPolicy = + mv_rootPOA->create_id_assignment_policy(PortableServer::USER_ID); + + // Policies for the new POA + CORBA::PolicyList policies(3); + policies.length (3); + policies[0] = v_threadingPolicy.in(); + policies[1] = v_lifespanPolicy.in(); + policies[2] = v_idAssignmentPolicy.in(); + + mv_thisPOA = mv_rootPOA->create_POA( + m_poaName.c_str(), + PortableServer::POAManager::_nil(), + policies + ); + + mv_poaManager = mv_thisPOA->the_POAManager(); + mv_poaManager->activate(); + } + catch(...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("activate failed\n"))); + return -1; + } + + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("POA activated\n"))); + + return 0; +} /* end of PersistentPoa::init ( ) */ + + +int PersistentPoa::fini (void) +{ + try + { + mv_poaManager->deactivate(1, 1); + mv_poaManager = PortableServer::POAManager::_nil(); + + mv_thisPOA->destroy(1, 1); + mv_thisPOA = PortableServer::POA::_nil(); + } + catch(...) + { + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("deactivate failed\n"))); + return -1; + } + + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("POA deactivated\n"))); + + return 0; +} /* end of PersistentPoa::fini ( ) */ + + +ACE_FACTORY_DEFINE (bug_3251, PersistentPoa) diff --git a/TAO/tests/Bug_3251_Regression/PersistentPoa.h b/TAO/tests/Bug_3251_Regression/PersistentPoa.h new file mode 100644 index 00000000000..dace9c4db7f --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/PersistentPoa.h @@ -0,0 +1,46 @@ +// $Id$ + +#ifndef bug_3251_PersistentPoa_h +#define bug_3251_PersistentPoa_h + +#include <string> + +#include "ace/Service_Object.h" +#include "tao/ORB.h" +#include "tao/PortableServer/PortableServer.h" + +#include "DllOrb.h" +#include "bug_3251_export.h" + + +class PersistentPoa +: + public ACE_Service_Object +{ + // public types and methods + public: + PersistentPoa ( ); + + ~PersistentPoa ( ) + throw (); + + // protected types and methods + protected: + virtual int init (int argc, char *argv[]); + + virtual int fini (void); + + // private methods and instance variables + private: + std::string m_poaName; + CORBA::ORB_var mv_orb; + PortableServer::POA_var mv_rootPOA; + PortableServer::POA_var mv_thisPOA; + PortableServer::POAManager_var mv_poaManager; +}; /* end of class PersistentPoa */ + + +ACE_FACTORY_DECLARE (bug_3251, PersistentPoa) + + +#endif /* bug_3251_PersistentPoa_h */ diff --git a/TAO/tests/Bug_3251_Regression/bug_3251_export.h b/TAO/tests/Bug_3251_Regression/bug_3251_export.h new file mode 100644 index 00000000000..55e3d892fab --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/bug_3251_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl bug_3251 +// ------------------------------ +#ifndef BUG_3251_REGRESSION_EXPORT_H +#define BUG_3251_REGRESSION_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (BUG_3251_REGRESSION_HAS_DLL) +# define BUG_3251_REGRESSION_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && BUG_3251_REGRESSION_HAS_DLL */ + +#if !defined (BUG_3251_REGRESSION_HAS_DLL) +# define BUG_3251_REGRESSION_HAS_DLL 1 +#endif /* ! BUG_3251_REGRESSION_HAS_DLL */ + +#if defined (BUG_3251_REGRESSION_HAS_DLL) && (BUG_3251_REGRESSION_HAS_DLL == 1) +# if defined (BUG_3251_REGRESSION_BUILD_DLL) +# define bug_3251_Export ACE_Proper_Export_Flag +# define BUG_3251_REGRESSION_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define BUG_3251_REGRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* BUG_3251_REGRESSION_BUILD_DLL */ +# define bug_3251_Export ACE_Proper_Import_Flag +# define BUG_3251_REGRESSION_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define BUG_3251_REGRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* BUG_3251_REGRESSION_BUILD_DLL */ +#else /* BUG_3251_REGRESSION_HAS_DLL == 1 */ +# define bug_3251_Export +# define BUG_3251_REGRESSION_SINGLETON_DECLARATION(T) +# define BUG_3251_REGRESSION_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* BUG_3251_REGRESSION_HAS_DLL == 1 */ + +// Set BUG_3251_REGRESSION_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (BUG_3251_REGRESSION_NTRACE) +# if (ACE_NTRACE == 1) +# define BUG_3251_REGRESSION_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define BUG_3251_REGRESSION_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !BUG_3251_REGRESSION_NTRACE */ + +#if (BUG_3251_REGRESSION_NTRACE == 1) +# define BUG_3251_REGRESSION_TRACE(X) +#else /* (BUG_3251_REGRESSION_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define BUG_3251_REGRESSION_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (BUG_3251_REGRESSION_NTRACE == 1) */ + +#endif /* BUG_3251_REGRESSION_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tests/Bug_3251_Regression/run_test.pl b/TAO/tests/Bug_3251_Regression/run_test.pl new file mode 100755 index 00000000000..bacca8c802f --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/run_test.pl @@ -0,0 +1,31 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::Run_Test; + +if (PerlACE::is_vxworks_test()) { + $SVP = new PerlACE::ProcessVX ("server", ""); +} +else { + $SVP = new PerlACE::Process ("server", ""); +} +# Run the AMH server. +$sv = $SVP->Spawn (); + +if ($sv != 0) { + print STDERR "ERROR: server returned $sv\n"; + exit 1; +} + +$svnk = $SVP->WaitKill (60); +if ($svnk != 0) { + print STDERR "ERROR: Server returned $svnk\n"; + $status = 1; +} + +exit $status; diff --git a/TAO/tests/Bug_3251_Regression/server.cpp b/TAO/tests/Bug_3251_Regression/server.cpp new file mode 100644 index 00000000000..4a7df9a97e1 --- /dev/null +++ b/TAO/tests/Bug_3251_Regression/server.cpp @@ -0,0 +1,132 @@ +// $Id$ + +#include "ace/ARGV.h" +#include "ace/OS.h" +#include "ace/Reactor.h" +#include "ace/Signal.h" +#include "ace/Service_Config.h" +#include "ace/Log_Msg.h" + +static volatile bool bShutdown = false; +static void shutdown(int) +{ + ACE_DEBUG ((LM_INFO, ACE_TEXT ("Shutdown requested\n"))); + bShutdown = true; +} + +int +ACE_TMAIN(int, ACE_TCHAR ** argv) +{ + int result = 0; +#if !defined (ACE_LACKS_FORK) + ACE_Sig_Action sigUSR2((ACE_SignalHandler) shutdown, SIGUSR2); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("SIGUSR2 shutdown handler installed\n"))); + ACE_UNUSED_ARG(sigUSR2); + + pid_t pid = -1; + pid = ACE_OS::fork(); + if (pid == 0) // child + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("child waiting\n"))); + ACE_OS::sleep(5); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("signaling parent\n"))); + result = ACE_OS::kill(ACE_OS::getppid(), SIGUSR2); + ACE_DEBUG ((LM_INFO, ACE_TEXT ("signaled parent\n"))); + return 0; + } + else if (pid > 0) // parent + { + ACE_DEBUG ((LM_INFO, ACE_TEXT ("parent using ACE_Service_Config\n"))); + ACE_Service_Config serviceConfig; + + char signum[64]; + ACE_OS::sprintf(signum, "%d", SIGUSR1); + + ACE_ARGV args; + args.add(argv[0]); + args.add("-s"); + args.add(signum); + + result = serviceConfig.open ( + args.argc(), + args.argv(), + ACE_DEFAULT_LOGGER_KEY, + 1, // ignore_static_svcs = 1, + 1, // ignore_default_svc_conf_file = 0, + 0 // ignore_debug_flag = 0 + ); + if(0 != result) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error: serviceConfig.open failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.open done\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.process_file ...\n"))); +#if (ACE_USES_CLASSIC_SVC_CONF == 1) + result = serviceConfig.process_file("Bug_3251.conf"); +#else + result = serviceConfig.process_file("Bug_3251.conf.xml"); +#endif + if(0 != result) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error: serviceConfig.process_file failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.process_file done\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("run_event_loop ...\n"))); + while(!bShutdown) + { + ACE_OS::last_error(0); + result = ACE_Reactor::run_event_loop(); + // reenter loop on EINTR + if(0 != result && EINTR == ACE_OS::last_error()) + { + if(bShutdown) + break; + } + else if(0 != result) + { + ACE_DEBUG (( + LM_INFO, + ACE_TEXT ("run_event_loop failed (%s, %d)\n"), + ACE_OS::strerror(ACE_OS::last_error()), + ACE_OS::last_error() + )); + } + } + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("run_event_loop done\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs ...\n"))); + result = serviceConfig.fini_svcs(); + if(0 != result) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error: serviceConfig.fini_svcs failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.fini_svcs done\n"))); + + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close ...\n"))); + result = serviceConfig.close(); + if(0 != result) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error: serviceConfig.close failed\n"))); + return result; + } + ACE_DEBUG ((LM_INFO, ACE_TEXT ("serviceConfig.close done\n"))); + + return result; + } /* end of if */ + else // fork failed + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("fork failed\n"))); + return 1; + } /* end of else */ +#else + ACE_UNUSED_ARG (argv); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Fork not available\n"))); +#endif + return result; +} |