diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.cpp | 26 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.h | 4 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel.cpp | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.cpp | 85 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.h | 13 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.cpp | 127 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.h | 13 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.cpp | 30 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.h | 4 |
9 files changed, 224 insertions, 81 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.cpp index 09e8a3fa84b..b3e84db9e32 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.cpp @@ -88,6 +88,32 @@ TAO_EC_ConsumerAdmin::disconnected (TAO_EC_ProxyPushSupplier *supplier, this->supplier_set_->disconnected (supplier, ACE_TRY_ENV); } +void +TAO_EC_ConsumerAdmin::shutdown (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_THROW_EX (TAO_EC_ConsumerAdmin::Busy_Lock, + ace_mon, this->busy_lock (), + RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + SupplierSetIterator end = this->end (); + for (SupplierSetIterator i = this->begin (); + i != end; + ++i) + { + ACE_TRY + { + (*i)->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + /* ignore all exceptions */ + } + ACE_ENDTRY; + } +} + RtecEventChannelAdmin::ProxyPushSupplier_ptr TAO_EC_ConsumerAdmin::obtain_push_supplier (CORBA::Environment &ACE_TRY_ENV) { diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.h b/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.h index 543ed30a456..52f070b9995 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Event/EC_ConsumerAdmin.h @@ -97,6 +97,10 @@ public: // Used to inform the EC that a Supplier has connected or // disconnected from it. + virtual void shutdown (CORBA::Environment&); + // The event channel is shutting down, inform all the consumers of + // this + // = The RtecEventChannelAdmin::ConsumerAdmin methods... virtual RtecEventChannelAdmin::ProxyPushSupplier_ptr obtain_push_supplier (CORBA::Environment &); diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel.cpp index bd221cfb3a7..db23a92dce5 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/EC_Event_Channel.cpp @@ -107,6 +107,9 @@ TAO_EC_Event_Channel::shutdown (CORBA::Environment& ACE_TRY_ENV) ACE_CHECK; supplier_poa->deactivate_object (supplier_id.in (), ACE_TRY_ENV); ACE_CHECK; + + this->consumer_admin_->shutdown (ACE_TRY_ENV); + this->supplier_admin_->shutdown (ACE_TRY_ENV); } void diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.cpp index c5e37b2a796..6e942c64645 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.cpp @@ -31,12 +31,6 @@ TAO_EC_ProxyPushConsumer::~TAO_EC_ProxyPushConsumer (void) this->event_channel_->destroy_consumer_lock (this->lock_); } -PortableServer::POA_ptr -TAO_EC_ProxyPushConsumer::_default_POA (CORBA::Environment&) -{ - return PortableServer::POA::_duplicate (this->default_POA_.in ()); -} - void TAO_EC_ProxyPushConsumer::connected (TAO_EC_ProxyPushSupplier* supplier, CORBA::Environment &ACE_TRY_ENV) @@ -65,6 +59,55 @@ TAO_EC_ProxyPushConsumer::disconnected (TAO_EC_ProxyPushConsumer*, { } +void +TAO_EC_ProxyPushConsumer::shutdown (CORBA::Environment &ACE_TRY_ENV) +{ + RtecEventComm::PushSupplier_var supplier; + + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + if (this->is_connected_i () == 0) + return; + + supplier = this->supplier_._retn (); + + this->cleanup_i (); + } + + this->deactivate (ACE_TRY_ENV); + ACE_CHECK; + + supplier->disconnect_push_supplier (ACE_TRY_ENV); +} + +void +TAO_EC_ProxyPushConsumer::cleanup_i (void) +{ + this->supplier_ = + RtecEventComm::PushSupplier::_nil (); + + this->filter_->unbind (this); + this->event_channel_->supplier_filter_builder ()->destroy (this->filter_); + this->filter_ = 0; +} + +void +TAO_EC_ProxyPushConsumer::deactivate (CORBA::Environment &ACE_TRY_ENV) +{ + PortableServer::POA_var poa = + this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (this, ACE_TRY_ENV); + ACE_CHECK; + poa->deactivate_object (id.in (), ACE_TRY_ENV); + ACE_CHECK; +} + CORBA::ULong TAO_EC_ProxyPushConsumer::_incr_refcnt (void) { @@ -106,12 +149,7 @@ TAO_EC_ProxyPushConsumer::connect_push_supplier ( // Re-connections are allowed, go ahead and disconnect the // consumer... - this->supplier_ = - RtecEventComm::PushSupplier::_nil (); - - this->filter_->unbind (this); - this->event_channel_->supplier_filter_builder ()->destroy (this->filter_); - this->filter_ = 0; + this->cleanup_i (); // @@ Please read the comments in EC_ProxySuppliers about // possible race conditions in this area... @@ -167,23 +205,12 @@ TAO_EC_ProxyPushConsumer::disconnect_push_consumer ( ACE_CHECK; if (this->is_connected_i () == 0) - ACE_THROW (CORBA::BAD_INV_ORDER ()); - - this->supplier_ = - RtecEventComm::PushSupplier::_nil (); + ACE_THROW (CORBA::BAD_INV_ORDER ()); // @@ add user exception? - this->filter_->unbind (this); - this->event_channel_->supplier_filter_builder ()->destroy (this->filter_); - this->filter_ = 0; + this->cleanup_i (); } - PortableServer::POA_var poa = - this->_default_POA (ACE_TRY_ENV); - ACE_CHECK; - PortableServer::ObjectId_var id = - poa->servant_to_id (this, ACE_TRY_ENV); - ACE_CHECK; - poa->deactivate_object (id.in (), ACE_TRY_ENV); + this->deactivate (ACE_TRY_ENV); ACE_CHECK; // Notify the event channel... @@ -192,6 +219,12 @@ TAO_EC_ProxyPushConsumer::disconnect_push_consumer ( this->_decr_refcnt (); } +PortableServer::POA_ptr +TAO_EC_ProxyPushConsumer::_default_POA (CORBA::Environment&) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} + void TAO_EC_ProxyPushConsumer::_add_ref (CORBA::Environment &) { diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.h b/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.h index 1659522d65a..528df12f129 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Event/EC_ProxyConsumer.h @@ -90,8 +90,8 @@ public: // Usually implemented as no-ops, but some configurations may // require this methods. - virtual PortableServer::POA_ptr _default_POA (CORBA::Environment& env); - // Override the ServantBase method. + virtual void shutdown (CORBA::Environment&); + // The event channel is shutting down CORBA::ULong _incr_refcnt (void); CORBA::ULong _decr_refcnt (void); @@ -106,7 +106,8 @@ public: CORBA::Environment &); virtual void disconnect_push_consumer (CORBA::Environment &); - // = Servant reference counting methods. + // = The Servant methods + virtual PortableServer::POA_ptr _default_POA (CORBA::Environment& env); virtual void _add_ref (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void _remove_ref (CORBA_Environment &ACE_TRY_ENV = @@ -116,6 +117,12 @@ private: CORBA::Boolean is_connected_i (void) const; // The private version (without locking) of is_connected(). + void cleanup_i (void); + // Release the filter and the supplier + + void deactivate (CORBA::Environment &ACE_TRY_ENV); + // Deactivate from the POA + private: TAO_EC_Event_Channel* event_channel_; // The supplier admin, used for activation and memory managment. diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.cpp index 9af16c805f7..cd8d9643f42 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.cpp @@ -31,56 +31,100 @@ TAO_EC_ProxyPushSupplier::~TAO_EC_ProxyPushSupplier (void) this->event_channel_->destroy_supplier_lock (this->lock_); } -CORBA::ULong -TAO_EC_ProxyPushSupplier::_incr_refcnt (void) +void +TAO_EC_ProxyPushSupplier::connected (TAO_EC_ProxyPushConsumer*, + CORBA::Environment &) { - ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); - return this->refcount_++; } -CORBA::ULong -TAO_EC_ProxyPushSupplier::_decr_refcnt (void) +void +TAO_EC_ProxyPushSupplier::disconnected (TAO_EC_ProxyPushConsumer*, + CORBA::Environment &) { - { - ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); - this->refcount_--; - if (this->refcount_ != 0) - return this->refcount_; - } - - // Notify the event channel - this->event_channel_->destroy_proxy_push_supplier (this); - return 0; } -PortableServer::POA_ptr -TAO_EC_ProxyPushSupplier::_default_POA (CORBA::Environment&) +void +TAO_EC_ProxyPushSupplier::connected (TAO_EC_ProxyPushSupplier*, + CORBA::Environment &) { - return PortableServer::POA::_duplicate (this->default_POA_.in ()); } void -TAO_EC_ProxyPushSupplier::connected (TAO_EC_ProxyPushConsumer*, - CORBA::Environment &) +TAO_EC_ProxyPushSupplier::disconnected (TAO_EC_ProxyPushSupplier*, + CORBA::Environment &) { } void -TAO_EC_ProxyPushSupplier::disconnected (TAO_EC_ProxyPushConsumer*, - CORBA::Environment &) +TAO_EC_ProxyPushSupplier::shutdown (CORBA::Environment &ACE_TRY_ENV) { + RtecEventComm::PushConsumer_var consumer; + + { + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + if (this->is_connected_i () == 0) + return; + + consumer = this->consumer_._retn (); + + this->cleanup_i (); + } + + this->deactivate (ACE_TRY_ENV); + ACE_CHECK; + + consumer->disconnect_push_consumer (ACE_TRY_ENV); } void -TAO_EC_ProxyPushSupplier::connected (TAO_EC_ProxyPushSupplier*, - CORBA::Environment &) +TAO_EC_ProxyPushSupplier::cleanup_i (void) { + this->consumer_ = + RtecEventComm::PushConsumer::_nil (); + + // @@ Why don't we have a destroy() method in the + // filter_builder? + delete this->child_; + this->child_ = 0; } void -TAO_EC_ProxyPushSupplier::disconnected (TAO_EC_ProxyPushSupplier*, - CORBA::Environment &) +TAO_EC_ProxyPushSupplier::deactivate (CORBA::Environment &ACE_TRY_ENV) { + PortableServer::POA_var poa = + this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + PortableServer::ObjectId_var id = + poa->servant_to_id (this, ACE_TRY_ENV); + ACE_CHECK; + poa->deactivate_object (id.in (), ACE_TRY_ENV); + ACE_CHECK; +} + +CORBA::ULong +TAO_EC_ProxyPushSupplier::_incr_refcnt (void) +{ + ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); + return this->refcount_++; +} + +CORBA::ULong +TAO_EC_ProxyPushSupplier::_decr_refcnt (void) +{ + { + ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0); + this->refcount_--; + if (this->refcount_ != 0) + return this->refcount_; + } + + // Notify the event channel + this->event_channel_->destroy_proxy_push_supplier (this); + return 0; } void @@ -102,13 +146,7 @@ TAO_EC_ProxyPushSupplier::connect_push_consumer ( // Re-connections are allowed, go ahead and disconnect the // consumer... - this->consumer_ = - RtecEventComm::PushConsumer::_nil (); - - // @@ Why don't we have a destroy() method in the - // filter_builder? - delete this->child_; - this->child_ = 0; + this->cleanup_i (); // @@ Are there any race conditions here: // + The lock is released, but the object is marked as @@ -168,21 +206,10 @@ TAO_EC_ProxyPushSupplier::disconnect_push_supplier ( if (this->is_connected_i () == 0) ACE_THROW (CORBA::BAD_INV_ORDER ()); - this->consumer_ = - RtecEventComm::PushConsumer::_nil (); - - // @@ Why don't we have a destroy() method in the filter_builder? - delete this->child_; - this->child_ = 0; + this->cleanup_i (); } - PortableServer::POA_var poa = - this->_default_POA (ACE_TRY_ENV); - ACE_CHECK; - PortableServer::ObjectId_var id = - poa->servant_to_id (this, ACE_TRY_ENV); - ACE_CHECK; - poa->deactivate_object (id.in (), ACE_TRY_ENV); + this->deactivate (ACE_TRY_ENV); ACE_CHECK; // Notify the event channel... @@ -404,6 +431,12 @@ TAO_EC_ProxyPushSupplier::can_match ( return this->child_->can_match (header); } +PortableServer::POA_ptr +TAO_EC_ProxyPushSupplier::_default_POA (CORBA::Environment&) +{ + return PortableServer::POA::_duplicate (this->default_POA_.in ()); +} + void TAO_EC_ProxyPushSupplier::_add_ref (CORBA::Environment &) { diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.h index e6bed2d9206..e5edd9cf6a7 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.h +++ b/TAO/orbsvcs/orbsvcs/Event/EC_ProxySupplier.h @@ -96,8 +96,8 @@ public: // Usually implemented as no-ops, but some configurations may // require this methods. - virtual PortableServer::POA_ptr _default_POA (CORBA::Environment& env); - // Override the ServantBase method. + virtual void shutdown (CORBA::Environment &env); + // The event channel is shutting down void push_to_consumer (const RtecEventComm::EventSet &event, CORBA::Environment &env); @@ -142,7 +142,8 @@ public: virtual CORBA::ULong max_event_size (void) const; virtual int can_match (const RtecEventComm::EventHeader &header) const; - // = Servant reference counting methods. + // = The Servant methods + virtual PortableServer::POA_ptr _default_POA (CORBA::Environment& env); virtual void _add_ref (CORBA_Environment &ACE_TRY_ENV = CORBA::default_environment ()); virtual void _remove_ref (CORBA_Environment &ACE_TRY_ENV = @@ -152,6 +153,12 @@ private: CORBA::Boolean is_connected_i (void) const; // The private version (without locking) of is_connected(). + void cleanup_i (void); + // Release the child and the consumer + + void deactivate (CORBA::Environment &ACE_TRY_ENV); + // Deactivate from the POA + private: TAO_EC_Event_Channel* event_channel_; // The Event Channel that owns this object. diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.cpp index 95a471dedc9..b1a0e9dd82a 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.cpp @@ -18,8 +18,8 @@ TAO_EC_SupplierAdmin::TAO_EC_SupplierAdmin (TAO_EC_Event_Channel *ec) this->event_channel_->supplier_poa (); // @@ We must consider using the techniques in the ConsumerAdmin - // also, i.e. not using locks but delaying operations that modify - // the set. I don't see much use for them right now, since there + // also, i.e. not using locks but delaying operations that modify + // the set. I don't see much use for them right now, since there // is no potential for dead-lock when dispatching events and/or // adding multiple suppliers and consumers, but we could avoid // some priority inversions. @@ -106,6 +106,32 @@ TAO_EC_SupplierAdmin::disconnected (TAO_EC_ProxyPushConsumer *consumer, ACE_THROW (RtecEventChannelAdmin::EventChannel::SUBSCRIPTION_ERROR ()); } +void +TAO_EC_SupplierAdmin::shutdown (CORBA::Environment &ACE_TRY_ENV) +{ + ACE_GUARD_THROW_EX ( + ACE_Lock, ace_mon, *this->lock_, + RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ()); + ACE_CHECK; + + ConsumerSetIterator end = this->end (); + for (ConsumerSetIterator i = this->begin (); + i != end; + ++i) + { + ACE_TRY + { + (*i)->shutdown (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + /* ignore all exceptions */ + } + ACE_ENDTRY; + } +} + RtecEventChannelAdmin::ProxyPushConsumer_ptr TAO_EC_SupplierAdmin::obtain_push_consumer (CORBA::Environment &ACE_TRY_ENV) { diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.h b/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.h index 3dc3032ebd9..d9beff66865 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.h +++ b/TAO/orbsvcs/orbsvcs/Event/EC_SupplierAdmin.h @@ -80,6 +80,10 @@ public: // Used to inform the EC that a Supplier has connected or // disconnected from it. + virtual void shutdown (CORBA::Environment&); + // The event channel is shutting down, inform all the consumers of + // this + // = The RtecEventChannelAdmin::SupplierAdmin methods... virtual RtecEventChannelAdmin::ProxyPushConsumer_ptr obtain_push_consumer (CORBA::Environment &); |