diff options
author | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-01-03 20:18:55 +0000 |
---|---|---|
committer | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-01-03 20:18:55 +0000 |
commit | 4b644b6deef058aee27e9b713495eac884fb101d (patch) | |
tree | 65631176f3f7e2ed878557ee9effc2c687721406 | |
parent | acd07f55fad146acf1b84e5bc69c42a802748fc4 (diff) | |
download | ATCD-4b644b6deef058aee27e9b713495eac884fb101d.tar.gz |
ChangeLogTag:Fri Jan 03 14:22:14 2003 Pradeep Gore <pradeep@oomworks.com>
-rw-r--r-- | TAO/ChangeLog | 53 | ||||
-rw-r--r-- | TAO/orbsvcs/Notify_Service/Notify_Server.cpp | 15 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Method_Request.h | 20 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl | 13 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Object.cpp | 6 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Peer.cpp | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Refcountable.h | 20 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl | 13 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp | 9 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp | 51 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h | 3 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Types.h | 3 |
15 files changed, 137 insertions, 85 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index a54b89399d4..981f8d830f6 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,56 @@ +Fri Jan 03 14:22:14 2003 Pradeep Gore <pradeep@oomworks.com> + + * orbsvcs/Notify_Service/Notify_Server.cpp: + Moved the call to <init> to catch any resulting exceptions and + exit gracefully. + + The following changes are made to fix the crashes observed on the + scoreboard in the $TAO_ROOT/orbsvcs/tests/Notify/Sequence_Multi_Test. + Thanks to Irfan and Bala for helping to fix this problem. + + * orbsvcs/orbsvcs/Notify/Container_T.cpp: + Changed the order of destruction of the Notify objects. The tree + is destroyed bottom up. This ensures that proxy objects that + refer to a valid parent during shutdown. + + * orbsvcs/orbsvcs/Notify/Method_Request.h: + * orbsvcs/orbsvcs/Notify/Method_Request.inl: + * orbsvcs/orbsvcs/Notify/Refcountable.h: + * orbsvcs/orbsvcs/Notify/Refcountable.inl: + Moved the TAO_NS_Refcountable_Guard class from Method_Request.* + files into Refcountable.* files. + + * orbsvcs/orbsvcs/Notify/Object.cpp: + Moved the <worker_task_> and <proxy_poa_> data member shutdown + from the destructor to the <shutdown> method. + + * orbsvcs/orbsvcs/Notify/Object_T.cpp: + Replaced the TAO_NS_Object_RefCount_Guard with + TAO_NS_Refcountable_Guard. + + * orbsvcs/orbsvcs/Notify/Peer.cpp: + Protect the Peer from being destroyed while it is dispatching + updates by using a TAO_NS_Refcountable_Guard. + + * orbsvcs/orbsvcs/Notify/Types.h: + Removed the TAO_NS_Object_RefCount_Guard class. We use + TAO_NS_Refcountable_Guard instead. + + * orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp: + * orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h: + Modified the <dequeue_available> method to return the number of + pending events. + + * orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp: + * orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h: + + Protect the call to the event batch <push> method with + TAO_NS_Refcountable_Guard so that the proxy (and hence this + peer) is not destroyed while the push is in progress. + + Reset the pacing error on dispatch error so that we don't + schedule a timer on an object that is about to be destroyed. + + Schedule a timer in the <handle_timeout> method only if there + are pending events. + Fri Jan 3 07:48:01 2003 Chad Elliott <elliott_c@ociweb.com> * tao/DynamicAny/DynamicAnyC.h: diff --git a/TAO/orbsvcs/Notify_Service/Notify_Server.cpp b/TAO/orbsvcs/Notify_Service/Notify_Server.cpp index 95521e73548..083d42c3e9a 100644 --- a/TAO/orbsvcs/Notify_Service/Notify_Server.cpp +++ b/TAO/orbsvcs/Notify_Service/Notify_Server.cpp @@ -22,17 +22,14 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) // ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); // Not handling signals. the shutdown code and event handler is maintained in case we want to address this in the future. - // Init factories. - ACE_DECLARE_NEW_CORBA_ENV; - - if (notify_service.init (argc, argv ACE_ENV_ARG_PARAMETER) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_LIB_TEXT("Failed to initialize the Notification Service.\n")), - 1); - - ACE_TRY + ACE_TRY_NEW_ENV { + if (notify_service.init (argc, argv ACE_ENV_ARG_PARAMETER) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_LIB_TEXT("Failed to initialize the Notification Service.\n")), + 1); + notify_service.run (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp index b8f86f25e8c..f2b0038c852 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp @@ -43,13 +43,16 @@ TAO_NS_Container_T<TYPE, OBJECT, PARENT>::~TAO_NS_Container_T () template <class TYPE, class OBJECT, class PARENT> void TAO_NS_Container_T<TYPE, OBJECT, PARENT>::shutdown (ACE_ENV_SINGLE_ARG_DECL) { - TAO_NS_Object_T<OBJECT, PARENT>::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - + // Destroy the leaves upwards.. + // First inform the children. TAO_ESF_Shutdown_Proxy<TYPE> shutdown_worker; this->collection_->for_each (&shutdown_worker ACE_ENV_ARG_PARAMETER); + // shutdown baseclass. + TAO_NS_Object_T<OBJECT, PARENT>::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + /// shutdown Container this->cleanup (ACE_ENV_SINGLE_ARG_PARAMETER); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h index b4c6b99df78..f16879b53e6 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h @@ -48,7 +48,7 @@ public: /** * @class TAO_NS_Method_Request_Event * -\ * @brief Base class for NS method Requests on Events. + * @brief Base class for NS method Requests on Events. * */ class TAO_Notify_Export TAO_NS_Method_Request_Event : public TAO_NS_Method_Request @@ -73,24 +73,6 @@ protected: const TAO_NS_Event_var event_; }; -/***********************************************************************/ - -/** - * @class TAO_NS_Refcountable_Guard - * - * @brief Ref. Count Guard - * - */ -class TAO_Notify_Export TAO_NS_Refcountable_Guard -{ -public: - TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable); - - ~TAO_NS_Refcountable_Guard (); - -protected: - TAO_NS_Refcountable& refcountable_; -}; #if defined (__ACE_INLINE__) #include "Method_Request.inl" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl index be75f075cd8..cfa1da318d3 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl @@ -1,14 +1 @@ // $Id$ - -ACE_INLINE -TAO_NS_Refcountable_Guard::TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable) - :refcountable_ (refcountable) -{ - this->refcountable_._incr_refcnt (); -} - -ACE_INLINE -TAO_NS_Refcountable_Guard::~TAO_NS_Refcountable_Guard () -{ - this->refcountable_._decr_refcnt (); -} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp index 0716a370040..12eb3f6b684 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp @@ -26,9 +26,6 @@ TAO_NS_Object::~TAO_NS_Object () { if (TAO_debug_level > 1 ) ACE_DEBUG ((LM_DEBUG,"object:%x destroyed\n", this )); - - this->shutdown_worker_task (); - this->shutdown_proxy_poa (); } void @@ -56,6 +53,9 @@ TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_DECL) { this->shutdown_ = 1; this->deactivate (ACE_ENV_SINGLE_ARG_PARAMETER); + + this->shutdown_worker_task (); + this->shutdown_proxy_poa (); } CORBA::Object_ptr diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp index 372773f3af6..54e3ba5ed57 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp @@ -26,7 +26,7 @@ TAO_NS_Object_T<TYPE, PARENT>::~TAO_NS_Object_T () template <class TYPE, class PARENT> void TAO_NS_Object_T<TYPE, PARENT>::destroy (TYPE *type ACE_ENV_ARG_DECL) { - TAO_NS_Object_RefCount_Guard guard (this->refcount_); + TAO_NS_Refcountable_Guard ref_guard(*this); // Protect this object from being destroyed in the middle of its shutdown sequence. this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp index 85f002570c0..09d7d08787d 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp @@ -84,6 +84,8 @@ TAO_NS_Peer::dispatch_updates (const TAO_NS_EventTypeSeq & added, const TAO_NS_E if (cos_added.length () != 0 || cos_removed.length () != 0) { + TAO_NS_Refcountable_Guard ref_guard(*this->proxy ()); // Protect this object from being destroyed in this scope. + this->dispatch_updates_i (cos_added, cos_removed ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h index 33dbbb22ed7..aa30f82be58 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h @@ -58,6 +58,26 @@ protected: TAO_NS_Destroy_Callback* destroy_callback_; }; +/***********************************************************************/ + +/** + * @class TAO_NS_Refcountable_Guard + * + * @brief Ref. Count Guard + * Increments the reference count in the constructor, the count is decremented when the guard's is destructor. + * + */ +class TAO_Notify_Export TAO_NS_Refcountable_Guard +{ +public: + TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable); + + ~TAO_NS_Refcountable_Guard (); + +protected: + TAO_NS_Refcountable& refcountable_; +}; + #if defined (__ACE_INLINE__) #include "Refcountable.inl" #endif /* __ACE_INLINE__ */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl index cfa1da318d3..be75f075cd8 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl @@ -1 +1,14 @@ // $Id$ + +ACE_INLINE +TAO_NS_Refcountable_Guard::TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable) + :refcountable_ (refcountable) +{ + this->refcountable_._incr_refcnt (); +} + +ACE_INLINE +TAO_NS_Refcountable_Guard::~TAO_NS_Refcountable_Guard () +{ + this->refcountable_._decr_refcnt (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp index a1918d6f271..1c819aa54ba 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.cpp @@ -23,9 +23,12 @@ TAO_NS_Batch_Buffering_Strategy::dequeue_batch (CosNotification::EventBatch& eve ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); // if batch_size is infinite, simply dequeue everything available. + + int pending = 0; // not used. + if (this->batch_size_ == 0) { - return this->dequeue_available (event_batch); + return this->dequeue_available (event_batch, pending); } else { @@ -43,7 +46,7 @@ TAO_NS_Batch_Buffering_Strategy::dequeue_batch (CosNotification::EventBatch& eve } int -TAO_NS_Batch_Buffering_Strategy::dequeue_available (CosNotification::EventBatch& event_batch) +TAO_NS_Batch_Buffering_Strategy::dequeue_available (CosNotification::EventBatch& event_batch, int &pending) { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->global_queue_lock_, -1); @@ -52,6 +55,8 @@ TAO_NS_Batch_Buffering_Strategy::dequeue_available (CosNotification::EventBatch& if (this->batch_size_ != 0 && deq_count > this->batch_size_) // Restrict upto batch size. deq_count = this->batch_size_; + pending = this->msg_queue_.message_count () - deq_count; + return this->dequeue_i (deq_count, event_batch); } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h index 31f13e50480..196f4a67242 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Batch_Buffering_Strategy.h @@ -43,7 +43,8 @@ public: /// Dequeue upto batch. This method will not block. /// Return -1 on error else the number of items dequeued (<batch_size>). - int dequeue_available (CosNotification::EventBatch& event_batch); + /// <pending> is set to the number of events remaining in the queue. + int dequeue_available (CosNotification::EventBatch& event_batch, int &pending); protected: diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp index bcfe9a18da0..9d099aa2269 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp @@ -46,8 +46,7 @@ TAO_NS_SequencePushConsumer::init (CosNotifyComm::SequencePushConsumer_ptr push_ void TAO_NS_SequencePushConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) { - if (this->timer_id_ != -1) - this->cancel_timer (); + this->cancel_timer (); } void @@ -86,22 +85,20 @@ TAO_NS_SequencePushConsumer::qos_changed (const TAO_NS_QoSProperties& qos_proper void TAO_NS_SequencePushConsumer::schedule_timer (void) { - if (this->timer_) - this->timer_id_ = this->timer_->schedule_timer (this, 0, this->pacing_interval_); - // Schedule the timer. - if (this->timer_id_ == -1) - this->pacing_interval_ = ACE_Time_Value::zero; // some error, revert to no pacing. + if (this->pacing_interval_ != ACE_Time_Value::zero) + { + this->timer_id_ = this->timer_->schedule_timer (this, this->pacing_interval_, 0); + + if (this->timer_id_ == -1) + this->pacing_interval_ = ACE_Time_Value::zero; // some error, revert to no pacing. + } } void TAO_NS_SequencePushConsumer::cancel_timer (void) { - if (this->timer_ && this->timer_id_ != -1) - { - timer_->cancel_timer (this->timer_id_); - this->timer_id_ = -1; - } + timer_->cancel_timer (this->timer_id_); } void @@ -144,20 +141,19 @@ int TAO_NS_SequencePushConsumer::handle_timeout (const ACE_Time_Value& /*current_time*/, const void* /*act*/) { - if (this->timer_id_ != -1) - this->cancel_timer (); - CosNotification::EventBatch event_batch; - int deq_count = this->buffering_strategy_->dequeue_available (event_batch); + int pending = 0; + + int deq_count = this->buffering_strategy_->dequeue_available (event_batch, pending); if (deq_count > 0) { - ACE_DECLARE_NEW_CORBA_ENV; + TAO_NS_Refcountable_Guard ref_guard(*this->proxy ()); // Protect this object from being destroyed in this scope. - this->push (event_batch ACE_ENV_ARG_PARAMETER); + this->push (event_batch); - if (this->pacing_interval_ != ACE_Time_Value::zero) + if (pending) this->schedule_timer (); } @@ -165,25 +161,20 @@ TAO_NS_SequencePushConsumer::handle_timeout (const ACE_Time_Value& /*current_tim } void -TAO_NS_SequencePushConsumer::push (const CosNotification::EventBatch& event_batch ACE_ENV_ARG_DECL) +TAO_NS_SequencePushConsumer::push (const CosNotification::EventBatch& event_batch) { - ACE_TRY + ACE_TRY_NEW_ENV { this->push_consumer_->push_structured_events (event_batch ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; } - ACE_CATCH (CORBA::OBJECT_NOT_EXIST, not_exist) - { - this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (CORBA::SystemException, sysex) + ACE_CATCHANY { this->handle_dispatch_exception (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_TRY_CHECK; - } - ACE_CATCHANY - { + + // we're scheduled to be destroyed. don't set the timer. + this->pacing_interval_ = ACE_Time_Value::zero; } ACE_ENDTRY; } diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h index 0b4ecc5d835..cc7f689b6ac 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h @@ -65,7 +65,7 @@ public: virtual void push (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL); /// Push <event> to this consumer. - virtual void push (const CosNotification::EventBatch& event ACE_ENV_ARG_DECL); + virtual void push (const CosNotification::EventBatch& event); /// Override, Peer::qos_changed virtual void qos_changed (const TAO_NS_QoSProperties& qos_properties); @@ -83,6 +83,7 @@ protected: void cancel_timer (void); ///= Protected Data Members + /// The Pacing Interval ACE_Time_Value pacing_interval_; diff --git a/TAO/orbsvcs/orbsvcs/Notify/Types.h b/TAO/orbsvcs/orbsvcs/Notify/Types.h index bc17a2bd0ec..2981078e10a 100644 --- a/TAO/orbsvcs/orbsvcs/Notify/Types.h +++ b/TAO/orbsvcs/orbsvcs/Notify/Types.h @@ -27,7 +27,6 @@ */ template <class PROXY> class TAO_ESF_Proxy_Collection; -template <class TYPE> class TAO_ESF_RefCount_Guard; template <class PROXY, class ACE_LOCK> class TAO_NS_Event_Map_T; /** @@ -64,8 +63,6 @@ typedef TAO_ESF_Proxy_Collection<TAO_NS_Consumer> TAO_NS_Consumer_Collection; typedef TAO_ESF_Proxy_Collection<TAO_NS_Supplier> TAO_NS_Supplier_Collection; typedef TAO_ESF_Proxy_Collection<TAO_NS_Peer> TAO_NS_Peer_Collection; -typedef TAO_ESF_RefCount_Guard<CORBA::ULong> TAO_NS_Object_RefCount_Guard; - typedef TAO_NS_Event_Map_T<TAO_NS_ProxySupplier, TAO_SYNCH_RW_MUTEX> TAO_NS_Consumer_Map; typedef TAO_NS_Event_Map_T<TAO_NS_ProxyConsumer, TAO_SYNCH_RW_MUTEX> TAO_NS_Supplier_Map; |