diff options
author | bala <balanatarajan@users.noreply.github.com> | 2002-04-22 23:13:25 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2002-04-22 23:13:25 +0000 |
commit | 0f42760f1ca55517413e41aa8b832aff6d110e7f (patch) | |
tree | 271a4422aef7f892b683495ea10dc2d47a1b5448 | |
parent | 2a0659d4332d763fbc91af13e9adf5ebe2778085 (diff) | |
download | ATCD-0f42760f1ca55517413e41aa8b832aff6d110e7f.tar.gz |
ChangeLogTag: Mon Apr 22 17:53:04 2002 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r-- | TAO/tao/ChangeLog | 12 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.h | 18 | ||||
-rw-r--r-- | TAO/tao/Connection_Handler.inl | 25 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connection_Handler.cpp | 11 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connection_Handler.h | 3 |
6 files changed, 70 insertions, 2 deletions
diff --git a/TAO/tao/ChangeLog b/TAO/tao/ChangeLog index 6cb6ea579cf..7c72cce026e 100644 --- a/TAO/tao/ChangeLog +++ b/TAO/tao/ChangeLog @@ -1,3 +1,15 @@ +Mon Apr 22 17:53:04 2002 Balachandran Natarajan <bala@cs.wustl.edu> + + * tao/Connection_Handler.cpp: + * tao/Connection_Handler.h: + * tao/Connection_Handler.inl: Added reference count to check the + life time of the handlers. Added a method shutdown_object () for + memory management. + + * tao/IIOP_Connection_Handler.cpp: + * tao/IIOP_Connection_Handler.h: Implement concrete + implementations for shutdown_object (). + Mon Apr 22 13:21:05 2002 Balachandran Natarajan <bala@cs.wustl.edu> * tao/Connect_Strategy.h: diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp index ee34affd389..6e04b73995c 100644 --- a/TAO/tao/Connection_Handler.cpp +++ b/TAO/tao/Connection_Handler.cpp @@ -22,6 +22,7 @@ TAO_Connection_Handler::TAO_Connection_Handler (TAO_ORB_Core *orb_core) transport_ (0), tss_resources_ (orb_core->get_tss_resources ()), pending_upcalls_ (1), + reference_count_ (1), pending_upcall_lock_ (0) { @@ -45,6 +46,8 @@ TAO_Connection_Handler::~TAO_Connection_Handler (void) TAO_Transport::release (this->transport_); delete this->pending_upcall_lock_; + + cout << " Amba I am going " << endl; } diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h index e869a0db2a4..d355723642c 100644 --- a/TAO/tao/Connection_Handler.h +++ b/TAO/tao/Connection_Handler.h @@ -63,6 +63,11 @@ public: /// Was the non-blocking connection initialization successful? int is_connect_successful (void) const; + /// Increment and decrement the refcount. The object is deleted when + /// the refcount reaches zero. + int incr_refcount (void); + void decr_refcount (void); + protected: /// Return our TAO_ORB_Core pointer @@ -90,6 +95,9 @@ protected: /// Query the upcall count int pending_upcalls (void) const; + /// Shutdown the object + virtual void shutdown_object (void) = 0; + private: /// Pointer to the TAO_ORB_Core TAO_ORB_Core *orb_core_; @@ -106,6 +114,16 @@ private: /// from the nested upcalls. long pending_upcalls_; + /* Have a count of the number of references to the + * handler. Theoretically this should be in the reactor. As we dont + * have this in the reactor we are providing it here. + * + * NOTE: Please dont try to combine this with the pending + * upcalls. They are for two completely different things. + * @@todo: Need to be moved into the reactor at a later date + */ + long reference_count_; + /// Lock for the <pending_upcalls_>. We can have more than one /// thread trying to access. ACE_Lock *pending_upcall_lock_; diff --git a/TAO/tao/Connection_Handler.inl b/TAO/tao/Connection_Handler.inl index 46aff581efd..32925823956 100644 --- a/TAO/tao/Connection_Handler.inl +++ b/TAO/tao/Connection_Handler.inl @@ -44,6 +44,31 @@ TAO_Connection_Handler::is_connect_successful (void) const } ACE_INLINE int +TAO_Connection_Handler::incr_refcount (void) +{ + ACE_GUARD_RETURN (ACE_Lock, + ace_mon, + *this->pending_upcall_lock_, -1); + + return ++this->reference_count_; +} + +ACE_INLINE void +TAO_Connection_Handler::decr_refcount (void) +{ + { + ACE_GUARD (ACE_Lock, + ace_mon, + *this->pending_upcall_lock_); + + --this->reference_count_; + } + + if (this->reference_count_ == 0) + this->shutdown_object (); +} + +ACE_INLINE int TAO_Connection_Handler::incr_pending_upcalls (void) { ACE_GUARD_RETURN (ACE_Lock, diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp index 38f2d51200b..87946dbd08c 100644 --- a/TAO/tao/IIOP_Connection_Handler.cpp +++ b/TAO/tao/IIOP_Connection_Handler.cpp @@ -57,6 +57,7 @@ TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (TAO_ORB_Core *orb_core TAO_IIOP_Connection_Handler::~TAO_IIOP_Connection_Handler (void) { + cout << " I am going " << endl; } int @@ -193,6 +194,7 @@ int TAO_IIOP_Connection_Handler::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask rm) { + ACE_OS::abort (); // @@ Alex: we need to figure out if the transport decides to close // us or something else. If it is something else (for example // the cached connector trying to make room for other @@ -263,13 +265,18 @@ TAO_IIOP_Connection_Handler::handle_close_i (void) // TAO_Transport::release (). this->transport (0); + // Decrement the refcount for automatic memory management + this->decr_refcount (); +} + +void +TAO_IIOP_Connection_Handler::shutdown_object (void) +{ // Follow usual Reactor-style lifecycle semantics and commit // suicide. this->destroy (); } - - int TAO_IIOP_Connection_Handler::resume_handler (void) { diff --git a/TAO/tao/IIOP_Connection_Handler.h b/TAO/tao/IIOP_Connection_Handler.h index f67c97810e7..dab072c4781 100644 --- a/TAO/tao/IIOP_Connection_Handler.h +++ b/TAO/tao/IIOP_Connection_Handler.h @@ -133,6 +133,9 @@ protected: /// ensure that server threads eventually exit. virtual int handle_input (ACE_HANDLE = ACE_INVALID_HANDLE); + // = Connection handler overload + virtual void shutdown_object (void); + private: /// Perform appropriate closing. |