summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2000-11-05 00:46:42 +0000
committerbala <balanatarajan@users.noreply.github.com>2000-11-05 00:46:42 +0000
commit50bc00fa2bceb9726e07de86fcd8009ed8983f98 (patch)
treec2936ea74b6ba85fedcb123dd79c8bcef85dd2b7
parent8522cfe4461541581a516a6942ab448a4d6495ac (diff)
downloadATCD-50bc00fa2bceb9726e07de86fcd8009ed8983f98.tar.gz
*** empty log message ***
-rw-r--r--TAO/tao/Base_Connection_Property.cpp34
-rw-r--r--TAO/tao/Base_Connection_Property.h113
-rw-r--r--TAO/tao/Base_Connection_Property.inl64
-rw-r--r--TAO/tao/Cache_Entries.cpp10
-rw-r--r--TAO/tao/Cache_Entries.h167
-rw-r--r--TAO/tao/Cache_Entries.inl164
-rw-r--r--TAO/tao/Connection_Cache_Manager.cpp317
-rw-r--r--TAO/tao/Connection_Cache_Manager.h219
-rw-r--r--TAO/tao/Connection_Cache_Manager.inl163
-rw-r--r--TAO/tao/Connection_Handler.cpp141
-rw-r--r--TAO/tao/Connection_Handler.h157
-rw-r--r--TAO/tao/Connection_Handler.inl67
12 files changed, 1616 insertions, 0 deletions
diff --git a/TAO/tao/Base_Connection_Property.cpp b/TAO/tao/Base_Connection_Property.cpp
new file mode 100644
index 00000000000..df3976860d6
--- /dev/null
+++ b/TAO/tao/Base_Connection_Property.cpp
@@ -0,0 +1,34 @@
+//$Id$
+
+#include "tao/Base_Connection_Property.h"
+
+
+
+#if !defined (__ACE_INLINE__)
+# include "tao/Base_Connection_Property.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(tao, Base_Connection_Property, "$Id$")
+
+
+TAO_Base_Connection_Property::~TAO_Base_Connection_Property (void)
+{
+ if (endpoint_flag_)
+ delete this->endpoint_;
+}
+
+
+TAO_Base_Connection_Property *
+TAO_Base_Connection_Property::duplicate (void)
+{
+ // Get a copy of the underlying endpoint
+ TAO_Endpoint *endpt = this->endpoint_->duplicate ();
+
+ // Construct a copy of our class
+ TAO_Base_Connection_Property *prop = 0;
+ ACE_NEW_RETURN (prop,
+ TAO_Base_Connection_Property (endpt,
+ 1),
+ 0);
+ return prop;
+}
diff --git a/TAO/tao/Base_Connection_Property.h b/TAO/tao/Base_Connection_Property.h
new file mode 100644
index 00000000000..d7c52c9ca16
--- /dev/null
+++ b/TAO/tao/Base_Connection_Property.h
@@ -0,0 +1,113 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// Connection_Property.h
+//
+// = AUTHOR
+// Bala Natarajan <bala@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef TAO_BASE_CONNECTION_PROPERTY_H
+#define TAO_BASE_CONNECTION_PROPERTY_H
+#include "ace/pre.h"
+
+#include "tao/Endpoint.h"
+
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+
+
+class TAO_Export TAO_Base_Connection_Property
+{
+ // = TITLE
+ // Abstracts the base properties of the connection, which will
+ // be used to look up connections in the cache
+ //
+ // = DESCRIPTION
+ // This class has the fundamental property of the connection
+ // viz. the peer to which it is connected. This class will be
+ // used to do a look up of the connection from the cache.
+ // Note 1: Additional properties for connection like Qos,
+ // Priority that the RT folks would need, can be added by
+ // inheriting from this class and providing the following
+ // methods.
+ // 1. duplicate ()
+ // 2. operator==
+ // 3. operator=
+ // 4. operator!=
+ // 5. hash ()
+public:
+
+ TAO_Base_Connection_Property (void);
+ // Default constructor
+
+
+ TAO_Base_Connection_Property (TAO_Endpoint *endpoint,
+ CORBA::Boolean flag = 0);
+ // Constructor
+
+ virtual ~TAO_Base_Connection_Property (void);
+ // Dtor
+
+ // = Operations that need to be overloaded in all the inherited
+ // classes. Without these the caching of connections may not work
+ // right way.
+
+ TAO_Base_Connection_Property (
+ const TAO_Base_Connection_Property &rhs);
+ // The copy constructor.
+
+ virtual TAO_Base_Connection_Property *duplicate (void);
+ // This call allocates and copies the contents of this class and
+ // returns the pointer
+
+ TAO_Endpoint *endpoint (void);
+ // Return the underlying endpoint oject
+
+ void operator= (const TAO_Base_Connection_Property &rhs);
+ // Assignment operator (does copy memory).
+
+ int operator== (const TAO_Base_Connection_Property &rhs) const;
+ // Equality comparison operator
+
+ int operator!= (const TAO_Base_Connection_Property &rhs) const;
+ // Inequality comparison operator.
+
+ u_long hash (void) const;
+ // Generate hash value for our class
+
+private:
+
+ TAO_Endpoint *endpoint_;
+ // The base property of the connection ie. the peer's endpoint
+ // Note: This endpoint will have a minimal info about the
+ // endpoint. This should not be used for any invocation.
+
+ CORBA::Boolean endpoint_flag_;
+ // Is the endpoint allocated on the heap? If so, we will have to
+ // delete it when we destruct ourselves.
+};
+
+#if defined (__ACE_INLINE__)
+# include "tao/Base_Connection_Property.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/post.h"
+#endif /*TAO_BASE_CONNECTION_PROPERTY_H*/
diff --git a/TAO/tao/Base_Connection_Property.inl b/TAO/tao/Base_Connection_Property.inl
new file mode 100644
index 00000000000..db1a946706b
--- /dev/null
+++ b/TAO/tao/Base_Connection_Property.inl
@@ -0,0 +1,64 @@
+/* -*- C++ -*- */
+// $Id$
+
+ACE_INLINE
+TAO_Base_Connection_Property::TAO_Base_Connection_Property (void)
+{
+
+}
+
+ACE_INLINE
+TAO_Base_Connection_Property::
+ TAO_Base_Connection_Property (TAO_Endpoint *endpoint,
+ CORBA::Boolean flag)
+ : endpoint_ (endpoint),
+ endpoint_flag_ (flag)
+{
+}
+
+
+ACE_INLINE TAO_Endpoint *
+TAO_Base_Connection_Property::endpoint (void)
+{
+ return this->endpoint_;
+}
+
+
+ACE_INLINE
+TAO_Base_Connection_Property::TAO_Base_Connection_Property (
+ const TAO_Base_Connection_Property &rhs)
+{
+ this->endpoint_ = rhs.endpoint_->duplicate ();
+ this->endpoint_flag_ = 1;
+}
+
+ACE_INLINE void
+TAO_Base_Connection_Property::operator= (
+ const TAO_Base_Connection_Property &rhs)
+{
+ if (this == &rhs)
+ return;
+
+ this->endpoint_ = rhs.endpoint_->duplicate ();
+ this->endpoint_flag_ = 1;
+}
+
+ACE_INLINE int
+TAO_Base_Connection_Property::operator== (
+ const TAO_Base_Connection_Property &rhs) const
+{
+ return this->endpoint_->is_equivalent (rhs.endpoint_);
+}
+
+ACE_INLINE int
+TAO_Base_Connection_Property::operator!= (
+ const TAO_Base_Connection_Property &rhs) const
+{
+ return !(this->endpoint_->is_equivalent (rhs.endpoint_));
+}
+
+ACE_INLINE u_long
+TAO_Base_Connection_Property::hash (void) const
+{
+ return this->endpoint_->hash ();
+}
diff --git a/TAO/tao/Cache_Entries.cpp b/TAO/tao/Cache_Entries.cpp
new file mode 100644
index 00000000000..c9b367e9de0
--- /dev/null
+++ b/TAO/tao/Cache_Entries.cpp
@@ -0,0 +1,10 @@
+//$Id$
+
+#include "tao/Cache_Entries.h"
+
+
+#if !defined (__ACE_INLINE__)
+# include "tao/Cache_Entries.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(tao, Cache_Entries, "$Id$")
diff --git a/TAO/tao/Cache_Entries.h b/TAO/tao/Cache_Entries.h
new file mode 100644
index 00000000000..f52acf4cc53
--- /dev/null
+++ b/TAO/tao/Cache_Entries.h
@@ -0,0 +1,167 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// Cache_Entries.h
+//
+// = AUTHOR
+// Bala Natarajan <bala@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef TAO_CACHE_ENTRIES_H
+#define TAO_CACHE_ENTRIES_H
+#include "ace/pre.h"
+
+#include "tao/Base_Connection_Property.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class TAO_Connection_Handler;
+class Tao_Base_Connection_Property;
+
+class TAO_Export TAO_Cache_IntId
+{
+ // = TITLE
+ // Helper class for TAO_Connection_Cache_Manager
+ //
+ // = DESCRIPTION
+ // Helper class that wraps the <value> part of the Map or
+ // table holding the Connection state.: unifies data items, so
+ // they can be stored together as a <value> for a <key> in a
+ // table holding the state of the Connection Cache.
+
+public:
+
+ // = Initialization and termination methods.
+
+ TAO_Cache_IntId (void);
+ // Constructor.
+
+ TAO_Cache_IntId (TAO_Connection_Handler *handler);
+ // Constructor.
+
+ TAO_Cache_IntId (const TAO_Cache_IntId & rhs);
+ // Copy constructor.
+
+ ~TAO_Cache_IntId (void);
+ // Destructor.
+
+ void operator= (const TAO_Cache_IntId &rhs);
+ // Assignment operator (does copy memory).
+
+ int operator== (const TAO_Cache_IntId &rhs) const;
+ // Equality comparison operator (must match both id_ and kind_).
+
+ int operator!= (const TAO_Cache_IntId &rhs) const;
+ // Inequality comparison operator.
+
+ TAO_Connection_Handler *handler (void);
+ // Return the underlying handler
+
+ const TAO_Connection_Handler *handler (void) const;
+ // Return the underlying handler
+
+ void recycle_state (ACE_Recyclable_State new_state);
+
+ ACE_Recyclable_State recycle_state (void);
+ // Get/Set <recycle_state>.
+
+private:
+
+ TAO_Connection_Handler *handler_;
+ // The connection handler that needs to be cached.
+
+ ACE_Recyclable_State recycle_state_;
+ // The state of the handle
+};
+
+
+class TAO_Export TAO_Cache_ExtId
+{
+ // = TITLE
+ // Helper class for TAO_Connection_Cache_Manager: unifies
+ // several data items, so they can be stored together as a
+ // <value> for a <key> in a hash table holding the state of the
+ // Connection Cache.
+ //
+ // = DESCRIPTION
+ //
+public:
+ // = Initialization and termination methods.
+
+ TAO_Cache_ExtId (void);
+ // Constructor.
+
+ TAO_Cache_ExtId (TAO_Base_Connection_Property *prop);
+ // Constructor.
+
+ TAO_Cache_ExtId (const TAO_Cache_ExtId & rhs);
+ // Copy constructor.
+
+ ~TAO_Cache_ExtId (void);
+ // Destructor.
+
+ // = Assignment and comparison operators.
+ void operator= (const TAO_Cache_ExtId &rhs);
+ // Assignment operator (does copy memory).
+
+ int operator== (const TAO_Cache_ExtId &rhs) const;
+ // Equality comparison operator (must match both id_ and kind_).
+
+ int operator!= (const TAO_Cache_ExtId &rhs) const;
+ // Inequality comparison operator.
+
+ u_long hash (void) const;
+ // <hash> function is required in order for this class to be usable by
+ // ACE_Hash_Map_Manager.
+
+ void duplicate (void);
+ // Make a deep copy of the underlying pointer
+
+ CORBA::ULong index (void);
+ // Return the index value
+
+ void index (CORBA::ULong index);
+ // Set the index value. This calls should not be used by any users
+ // but for the TAO_Connection_Cache_Manager class.
+
+ // = Accessors
+
+private:
+ // = Data members.
+
+ TAO_Base_Connection_Property *connection_property_;
+ // A property object that we represent.
+
+ CORBA::Boolean is_delete_;
+ // Do we need to delete connection_propert_?
+
+ CORBA::ULong index_;
+ // This is a supplementary index. Would be set to zero by
+ // default. Would be altered by the Connection_Cache of TAO. Please
+ // see the documentation of TAO_Connection_Cache_Manager for
+ // details.
+};
+
+
+#if defined (__ACE_INLINE__)
+# include "tao/Cache_Entries.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/post.h"
+#endif /* TAO_CACHE_ENTRIES_H */
diff --git a/TAO/tao/Cache_Entries.inl b/TAO/tao/Cache_Entries.inl
new file mode 100644
index 00000000000..ed526caabe3
--- /dev/null
+++ b/TAO/tao/Cache_Entries.inl
@@ -0,0 +1,164 @@
+/* -*- C++ -*- */
+// $Id$
+
+ACE_INLINE
+TAO_Cache_IntId::TAO_Cache_IntId (void)
+ : handler_ (0),
+ recycle_state_ (ACE_RECYCLABLE_UNKNOWN)
+{
+}
+
+ACE_INLINE
+TAO_Cache_IntId::TAO_Cache_IntId (TAO_Connection_Handler *handler)
+ : handler_ (handler)
+{
+}
+
+ACE_INLINE
+TAO_Cache_IntId::TAO_Cache_IntId (const TAO_Cache_IntId &rhs)
+{
+ this->handler_ = rhs.handler_;
+}
+
+ACE_INLINE
+TAO_Cache_IntId::~TAO_Cache_IntId (void)
+{
+}
+
+ACE_INLINE void
+TAO_Cache_IntId::operator= (const TAO_Cache_IntId &rhs)
+{
+ this->handler_ = rhs.handler_;
+}
+
+ACE_INLINE int
+TAO_Cache_IntId::operator== (const TAO_Cache_IntId &rhs) const
+{
+ return (this->handler_ == rhs.handler_);
+}
+
+ACE_INLINE int
+TAO_Cache_IntId::operator!= (const TAO_Cache_IntId &rhs) const
+{
+ return (this->handler_ != rhs.handler_);
+}
+
+ACE_INLINE TAO_Connection_Handler *
+TAO_Cache_IntId::handler (void)
+{
+ return this->handler_;
+}
+
+ACE_INLINE const TAO_Connection_Handler *
+TAO_Cache_IntId::handler (void) const
+{
+ return this->handler_;
+}
+
+ACE_INLINE void
+TAO_Cache_IntId::recycle_state (ACE_Recyclable_State st)
+{
+ this->recycle_state_ = st;
+}
+
+ACE_INLINE ACE_Recyclable_State
+TAO_Cache_IntId::recycle_state (void)
+{
+ return this->recycle_state_;
+}
+
+
+/*******************************************************/
+ACE_INLINE
+TAO_Cache_ExtId::TAO_Cache_ExtId (void)
+ : connection_property_ (0),
+ is_delete_ (0),
+ index_ (0)
+{
+}
+
+ACE_INLINE
+TAO_Cache_ExtId::TAO_Cache_ExtId (TAO_Base_Connection_Property *prop)
+ : connection_property_ (prop),
+ is_delete_ (0),
+ index_ (0)
+{
+
+}
+
+ACE_INLINE
+TAO_Cache_ExtId::~TAO_Cache_ExtId (void)
+{
+ if (this->is_delete_)
+ delete this->connection_property_;
+}
+
+ACE_INLINE
+TAO_Cache_ExtId::TAO_Cache_ExtId (const TAO_Cache_ExtId &rhs)
+{
+ // Do a deep copy
+ this->connection_property_ =
+ rhs.connection_property_->duplicate ();
+ this->is_delete_ = 1;
+ this->index_ = rhs.index_;
+}
+
+ACE_INLINE void
+TAO_Cache_ExtId::operator= (const TAO_Cache_ExtId &rhs)
+{
+ // Do a deep copy
+ this->connection_property_ =
+ rhs.connection_property_->duplicate ();
+ this->is_delete_ = 1;
+ this->index_ = rhs.index_;
+}
+
+ACE_INLINE int
+TAO_Cache_ExtId::operator== (const TAO_Cache_ExtId &rhs) const
+{
+ return (*this->connection_property_ == *rhs.connection_property_ &&
+ this->index_ == rhs.index_);
+}
+
+ACE_INLINE int
+TAO_Cache_ExtId::operator!= (const TAO_Cache_ExtId &rhs) const
+{
+ return (*this->connection_property_ != *rhs.connection_property_ ||
+ this->index_ != rhs.index_);
+}
+
+ACE_INLINE u_long
+TAO_Cache_ExtId::hash (void) const
+{
+ return (this->connection_property_->hash () + this->index_);
+}
+
+ACE_INLINE void
+TAO_Cache_ExtId::duplicate (void)
+{
+ TAO_Base_Connection_Property *prop = 0;
+
+ // Make a deep copy
+ prop = this->connection_property_->duplicate ();
+
+
+ // Release memory if there was some allocated in the first place
+ if (this->is_delete_)
+ delete this->connection_property_;
+
+ this->is_delete_ = 1;
+ this->connection_property_ = prop;
+}
+
+
+ACE_INLINE CORBA::ULong
+TAO_Cache_ExtId::index (void)
+{
+ return this->index_;
+}
+
+ACE_INLINE void
+TAO_Cache_ExtId::index (CORBA::ULong index)
+{
+ this->index_ = index;
+}
diff --git a/TAO/tao/Connection_Cache_Manager.cpp b/TAO/tao/Connection_Cache_Manager.cpp
new file mode 100644
index 00000000000..e7a22468a5a
--- /dev/null
+++ b/TAO/tao/Connection_Cache_Manager.cpp
@@ -0,0 +1,317 @@
+#include "tao/Connection_Cache_Manager.h"
+#include "tao/Connection_Handler.h"
+#include "tao/debug.h"
+
+
+#if !defined (__ACE_INLINE__)
+# include "tao/Connection_Cache_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+
+ACE_RCSID(tao, Connection_Cache_Hash_Manager, "$Id$")
+
+
+TAO_Connection_Cache_Manager::
+ TAO_Connection_Cache_Manager (void)
+ : cache_map_ ()
+{
+ ACE_NEW (this->cache_lock_,
+ ACE_Lock_Adapter<ACE_SYNCH_MUTEX>);
+}
+
+TAO_Connection_Cache_Manager::~TAO_Connection_Cache_Manager (void)
+{
+ // Delete the lock that we have
+ delete this->cache_lock_;
+}
+
+
+
+int
+TAO_Connection_Cache_Manager::bind_i (TAO_Cache_ExtId &ext_id,
+ TAO_Cache_IntId &int_id)
+{
+ // Get the entry too
+ HASH_MAP_ENTRY *entry = 0;
+ int retval = this->cache_map_.bind (ext_id,
+ int_id,
+ entry);
+ if (retval == 0)
+ {
+ // The entry has been added to cache succesfully
+ // Add the cache_map_entry to the handler
+ int_id.handler () ->cache_map_entry (entry);
+ }
+ else if (retval == 1)
+ {
+ if (TAO_debug_level > 0 && retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) TAO_Connection_Cache_Manager::bind_i")
+ ACE_TEXT (" unable to bind in the first attempt")
+ ACE_TEXT (" so trying with a new index \n")));
+ }
+
+ // There was an entry like this before, so let us do some
+ // minor adjustments
+ retval = this->get_last_index_bind (ext_id,
+ int_id,
+ entry);
+ if (retval == 0)
+ int_id.handler ()->cache_map_entry (entry);
+ }
+
+ if (TAO_debug_level > 0 && retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) TAO_Connection_Cache_Manager::bind_i")
+ ACE_TEXT (" unable to bind \n")));
+ }
+
+ return retval;
+}
+
+
+int
+TAO_Connection_Cache_Manager::find_i (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value)
+{
+ HASH_MAP_ENTRY *entry = 0;
+
+ // Get the entry from the Hash Map
+ int retval = this->cache_map_.find (key,
+ entry);
+ if (retval == 0)
+ {
+ retval = this->get_idle_handler (key,
+ entry);
+
+ // We have a succesful entry
+ if (entry)
+ {
+ value = entry->int_id_;
+ }
+
+ if (TAO_debug_level > 0 && retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) TAO_Connection_Cache_Manager::find_i")
+ ACE_TEXT (" unable to locate a free connection \n")));
+ }
+ }
+
+
+ return retval;
+}
+
+int
+TAO_Connection_Cache_Manager::rebind_i (const TAO_Cache_ExtId &key,
+ const TAO_Cache_IntId &value)
+{
+ return this->cache_map_.rebind (key,
+ value);
+}
+
+int
+TAO_Connection_Cache_Manager::trybind_i (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value)
+{
+ return this->cache_map_.trybind (key, value);
+}
+
+int
+TAO_Connection_Cache_Manager::unbind_i (const TAO_Cache_ExtId &key)
+{
+ return this->cache_map_.unbind (key);
+}
+
+int
+TAO_Connection_Cache_Manager::unbind_i (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value)
+{
+ return this->cache_map_.unbind (key,
+ value);
+}
+
+int
+TAO_Connection_Cache_Manager::make_idle_i (HASH_MAP_ENTRY *&entry)
+{
+
+ // First get the entry again (if at all things had changed in the
+ // cache map in the mean time)
+ HASH_MAP_ENTRY *new_entry = 0;
+ int retval = this->cache_map_.find (entry->ext_id_,
+ new_entry);
+ if (retval == 0)
+ {
+ new_entry->int_id_.
+ recycle_state (ACE_RECYCLABLE_IDLE_AND_PURGABLE);
+
+ entry = new_entry;
+ }
+ else if (TAO_debug_level > 0 && retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) TAO_Connection_Cache_Manager::make_idle_i")
+ ACE_TEXT ("unable to locate the entry to make it idle \n")));
+ }
+
+ return retval;
+}
+
+int
+TAO_Connection_Cache_Manager::mark_closed_i (HASH_MAP_ENTRY *&entry)
+{
+ // First get the entry again (if at all things had changed in the
+ // cache map in the mean time)
+ HASH_MAP_ENTRY *new_entry = 0;
+
+ int retval = this->cache_map_.find (entry->ext_id_,
+ new_entry);
+ if (retval == 0)
+ {
+ new_entry->int_id_.
+ recycle_state (ACE_RECYCLABLE_CLOSED);
+
+ entry = new_entry;
+ }
+ else if (TAO_debug_level > 0 && retval != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%P|%t) TAO_Connection_Cache_Manager::make_idle_i")
+ ACE_TEXT ("unable to locate the entry to mark it as closed \n")));
+ }
+
+ return retval;
+}
+
+int
+TAO_Connection_Cache_Manager::close_i (ACE_Handle_Set &handle_set)
+{
+
+
+ for (HASH_MAP_ITER iter = this->cache_map_.begin ();
+ iter != this->cache_map_.end ();
+ iter ++)
+ {
+
+ // Should I look for IDLE & PURGABLE ones to remove? That would
+ // sound odd as we would be called at ORB destruction time. So,
+ // we should just go ahead and remove the entries from the map
+
+ // As a first step, check whether the handler has been
+ // registered with the reactor. If registered, then get the
+ // handle and set that in the <handle_set> so that the ORB_Core
+ // would deregister them from the reactor before shutdown.
+ if ((*iter).int_id_.handler ()->is_registered ())
+ {
+ handle_set.set_bit ((*iter).int_id_.handler ()->fetch_handle ());
+ }
+
+ // Then decrement the reference count on the handler
+ (*iter).int_id_.handler ()->decr_ref_count ();
+
+ // Then remove the entry from the map
+ // @@ When I get the purging ready, I should call purge () from
+ // here.
+ HASH_MAP_ENTRY &entry = (*iter);
+
+ this->cache_map_.unbind (&entry);
+ }
+
+ return 0;
+}
+
+int
+TAO_Connection_Cache_Manager::
+ get_last_index_bind (TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &val,
+ HASH_MAP_ENTRY *&entry)
+{
+ CORBA::ULong ctr = entry->ext_id_.index ();
+
+ // Start looking at the succesive elements
+ while (entry->next_ != 0 &&
+ entry->next_->ext_id_.index () != 0)
+ {
+ ctr++;
+
+ // Change the entry
+ entry = entry->next_;
+ }
+
+ // Set the index
+ key.index (ctr + 1);
+
+ // Now do a bind again with the new index
+ return this->cache_map_.bind (key,
+ val,
+ entry);
+}
+
+
+int
+TAO_Connection_Cache_Manager::
+ get_idle_handler (const TAO_Cache_ExtId & /*ext_id*/,
+ HASH_MAP_ENTRY *&entry)
+{
+ // We are sure that we have an entry
+ do
+ {
+ // Found the entry, so check whether it is busy
+ if (entry->int_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
+ entry->int_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)
+ {
+ // Save that in the handler
+ entry->int_id_.handler ()->cache_map_entry (entry);
+
+ // Mark the connection as busy
+ entry->int_id_.recycle_state (ACE_RECYCLABLE_BUSY);
+ return 0;
+ }
+ else
+ {
+ entry = entry->next_;
+ }
+ }
+ // This would prevent us from moving to the next ext_id..
+ while (entry->next_->ext_id_.index () != 0);
+
+ // @@ There is a subtle assumption that I have made, ie. the
+ // elements with higher indexes of ext_id will be placed
+ // continously. That could be *bad*
+
+ // We havent got a connection, so set the pointer to null.
+ entry = 0;
+ return -1;
+}
+
+#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
+
+ // Instantiations for the Hash Map
+template class ACE_Equal_To<TAO_Cache_ExtId>;
+template class ACE_Hash<TAO_Cache_ExtId>;
+template class ACE_Hash_Map_Entry<TAO_Cache_ExtId, TAO_Cache_IntId>;
+template class ACE_Hash_Map_Manager<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Manager_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Base_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Iterator_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>;
+template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>;
+
+#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
+
+ // Instantiations for the Hash Map
+#pragma instantiate ACE_Equal_To<TAO_Cache_ExtId>
+#pragma instantiate ACE_Hash<TAO_Cache_ExtId>
+#pragma instantiate ACE_Hash_Map_Entry<TAO_Cache_ExtId, TAO_Cache_IntId>
+#pragma instantiate ACE_Hash_Map_Manager<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Iterator_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>
+#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Cache_ExtId, TAO_Cache_IntId, ACE_Hash<TAO_Cache_ExtId>, ACE_Equal_To<TAO_Cache_ExtId>, ACE_Null_Mutex>
+
+#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/tao/Connection_Cache_Manager.h b/TAO/tao/Connection_Cache_Manager.h
new file mode 100644
index 00000000000..fb023d084a6
--- /dev/null
+++ b/TAO/tao/Connection_Cache_Manager.h
@@ -0,0 +1,219 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// Connection_Cache_Manager.h
+//
+// = AUTHOR
+// Bala Natarajan <bala@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef TAO_CONNECTION_CACHE_MANAGER_H
+#define TAO_CONNECTION_CACHE_MANAGER_H
+#include "ace/pre.h"
+
+#include "ace/Hash_Map_Manager_T.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+#define ACE_LACKS_PRAGMA_ONCE
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/TAO_Export.h"
+#include "tao/Cache_Entries.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class TAO_Cache_ExtId;
+class TAO_Cache_IntId;
+
+class TAO_Export TAO_Connection_Cache_Manager
+{
+ // = TITLE
+ // The Connection Cache Manager for TAO
+
+ // = DESCRIPTION
+ // This class provides interfaces associating a TAO_Cache_ExtId
+ // & TAO_Cache_IntId. This class manages a ACE_Hash_Map_Manager
+ // class which is used as a container to Cache the
+ // connections. This class protects the entries with a lock. The
+ // map can be updated only by holding the lock.
+
+public:
+
+ // Some useful typedef's
+ typedef ACE_Hash_Map_Manager <TAO_Cache_ExtId,
+ TAO_Cache_IntId,
+ ACE_Null_Mutex>
+ HASH_MAP;
+
+ typedef ACE_Hash_Map_Iterator <TAO_Cache_ExtId,
+ TAO_Cache_IntId,
+ ACE_Null_Mutex>
+ HASH_MAP_ITER;
+
+ typedef ACE_Hash_Map_Entry <TAO_Cache_ExtId,
+ TAO_Cache_IntId>
+ HASH_MAP_ENTRY;
+
+ // == Public methods
+
+ TAO_Connection_Cache_Manager (void);
+ // Constructor
+
+ virtual ~TAO_Connection_Cache_Manager (void);
+ // Destructor
+
+ int cache_handler (TAO_Base_Connection_Property *prop,
+ TAO_Connection_Handler *handler);
+ // Add the handler to the cache. The handler has the property
+ // definition based on which caching can be done
+
+
+ int find_handler (TAO_Base_Connection_Property *prop,
+ TAO_Connection_Handler *&handler);
+ // Check the Connection Cache to check whether the connection exists
+ // in the Cache and return the connection
+
+ int open (size_t size = ACE_DEFAULT_MAP_SIZE,
+ ACE_Allocator *alloc = 0);
+ // Initialize a <HASH_MAP> with <size> elements.
+
+ int bind (TAO_Cache_ExtId &ext_id,
+ TAO_Cache_IntId &int_id);
+ // Associate <ext_id> with <int_id>. Grabs the lock and calls the
+ // implementation function bind_i.
+
+ int find (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value);
+ // Lookup entry<key,value> in the cache. Grabs the lock and calls the
+ // implementation function find_i.
+
+ int rebind (const TAO_Cache_ExtId &key,
+ const TAO_Cache_IntId &value);
+ // Reassociate the <key> with <value>. Grabs the lock and calls the
+ // implementation function find_i.
+
+ int trybind (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value);
+ // Associate <key> with <value> if and only if <key> is not in the
+ // cache. Grabs the lock and calls the implementation function
+ // find_i.
+
+ int unbind (const TAO_Cache_ExtId &key);
+ // Remove <key> from the cache.
+
+ int unbind (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value);
+ // Remove <key> from the cache, and return the <value> associated with
+ // <key>.
+
+ int purge (void);
+ // Remove entries from the cache depending upon the strategy.
+
+ int make_idle (HASH_MAP_ENTRY *&entry);
+ // Make the entry idle and ready for use.
+
+ int mark_closed (HASH_MAP_ENTRY *&entry);
+ // Mark the entry as closed
+
+ int close (ACE_Handle_Set &handle_set);
+ // Close the underlying hash map manager and return the handle set
+ // that have been registered with the reactor
+
+ size_t current_size (void) const;
+ // Return the current size of the cache.
+
+ size_t total_size (void) const;
+ // Return the total size of the cache.
+
+private:
+
+ int bind_i (TAO_Cache_ExtId &ext_id,
+ TAO_Cache_IntId &int_id);
+ // Non-Locking version and actual implementation of bind ()
+ // call. Calls bind on the Hash_Map_Manager that it holds. If the
+ // bind succeeds, it adds the Hash_Map_Entry in to the
+ // Connection_Handler for its reference. If the bind fails because
+ // of an exiting entry, this method calls the get_last_index_bind
+ // ().
+
+ int find_i (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value);
+ // Non-locking version and actual implementation of find ()
+ // call. This calls the find () on the underlying
+ // Hash_Map_Manager. If the find succeeds, it calls the
+ // get_idle_handler ().
+
+ int rebind_i (const TAO_Cache_ExtId &key,
+ const TAO_Cache_IntId &value);
+ // Non-locking version and actual implementation of rebind () call
+
+ int trybind_i (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value);
+ // Non-locking version and actual implementation of trybind () call
+
+ int unbind_i (const TAO_Cache_ExtId &key);
+ // Non-locking version and actual implementation of unbind () call
+
+ int unbind_i (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value);
+ // Non-locking version and actual implementation of unbind () call
+
+ int make_idle_i (HASH_MAP_ENTRY *&entry);
+ // Non-locking version and actual implementation of make_idle ().
+
+ int mark_closed_i (HASH_MAP_ENTRY *&entry);
+ // Non-locking version and actual implementation of mark_closed ()
+
+ int close_i (ACE_Handle_Set &handle_set);
+ // Non-locking version and actual implementation of close ()
+
+private:
+
+ int get_last_index_bind (TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &val,
+ HASH_MAP_ENTRY *&entry);
+ // This is called by the bind () call when a bind fails with a
+ // available entry. When a new connection is created in TAO with an
+ // already existing endpoint, in addition to an exisitng one, we
+ // mark the connections with an index. This method, finds out the
+ // last highest index and binds the entry with an index = (last
+ // highest index + 1).
+
+ int get_idle_handler (const TAO_Cache_ExtId &ext_id,
+ HASH_MAP_ENTRY *&entry);
+ // This is called by the find (). Get an idle handler if one is
+ // available in Cache. If an idle one does not exist, we look at the
+ // next entry to see whether we have an entry of the same ext_id
+ // type. If so, we check whether they are are idle for use. If we
+ // find one we mark it busy, and set the Hash_Map_Entry in the
+ // Connection_Handler object.
+
+
+
+private:
+
+ HASH_MAP cache_map_;
+ // The hash map that has the connections
+
+ ACE_Lock *cache_lock_;
+ // Lock for the map
+};
+
+#if defined (__ACE_INLINE__)
+# include "tao/Connection_Cache_Manager.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/post.h"
+#endif /*TAO_CONNECTION_CACHE_MANAGER_H*/
diff --git a/TAO/tao/Connection_Cache_Manager.inl b/TAO/tao/Connection_Cache_Manager.inl
new file mode 100644
index 00000000000..6a3f7c518f3
--- /dev/null
+++ b/TAO/tao/Connection_Cache_Manager.inl
@@ -0,0 +1,163 @@
+/* -*- C++ -*- */
+//$Id$
+
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::
+ cache_handler (TAO_Base_Connection_Property *prop,
+ TAO_Connection_Handler *handler)
+{
+ // Compose the ExternId & Intid
+ TAO_Cache_ExtId ext_id (prop);
+ TAO_Cache_IntId int_id (handler);
+
+ return this->bind (ext_id,
+ int_id);
+
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::
+ find_handler (TAO_Base_Connection_Property *prop,
+ TAO_Connection_Handler *&handler)
+{
+ // Compose the ExternId
+ TAO_Cache_ExtId ext_id (prop);
+ TAO_Cache_IntId int_id;
+
+ int retval = this->find (ext_id,
+ int_id);
+ if (retval == 0)
+ {
+ handler = int_id.handler ();
+ }
+
+ return retval;
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::bind (TAO_Cache_ExtId &ext_id,
+ TAO_Cache_IntId &int_id)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->bind_i (ext_id,
+ int_id);
+}
+
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::find (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->find_i (key,
+ value);
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::rebind (const TAO_Cache_ExtId &key,
+ const TAO_Cache_IntId &value)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->rebind_i (key,
+ value);
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::trybind (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->trybind_i (key, value);
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::unbind (const TAO_Cache_ExtId &key)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->unbind_i (key);
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::unbind (const TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &value)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->unbind_i (key,
+ value);
+}
+
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::purge (void)
+{
+ return 0;
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::make_idle (HASH_MAP_ENTRY *&entry)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+ return this->make_idle_i (entry);
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::mark_closed (HASH_MAP_ENTRY *&entry)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+ return this->mark_closed_i (entry);
+}
+
+ACE_INLINE int
+TAO_Connection_Cache_Manager::close (ACE_Handle_Set &handle_Set)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->cache_lock_,
+ -1));
+
+ return this->close_i (handle_Set);
+}
+
+
+ACE_INLINE size_t
+TAO_Connection_Cache_Manager::current_size (void) const
+{
+ return this->cache_map_.current_size ();
+}
+
+ACE_INLINE size_t
+TAO_Connection_Cache_Manager::total_size (void) const
+{
+ return this->cache_map_.total_size ();
+}
diff --git a/TAO/tao/Connection_Handler.cpp b/TAO/tao/Connection_Handler.cpp
new file mode 100644
index 00000000000..1ef786d611c
--- /dev/null
+++ b/TAO/tao/Connection_Handler.cpp
@@ -0,0 +1,141 @@
+//$Id$
+#include "tao/Connection_Handler.h"
+#include "tao/ORB_Core.h"
+#include "tao/Server_Strategy_Factory.h"
+#include "tao/debug.h"
+#include "tao/Object.h"
+#include "tao/Messaging_Policy_i.h"
+
+#if !defined (__ACE_INLINE__)
+#include "tao/Connection_Handler.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID(tao, Connection_Handler, "$Id$")
+
+TAO_Connection_Handler::TAO_Connection_Handler (TAO_ORB_Core *orb_core)
+ :orb_core_ (orb_core),
+ tss_resources_ (orb_core->get_tss_resources ()),
+ ref_count_ (1),
+ cache_map_entry_ (0),
+ is_registered_ (0)
+{
+}
+
+
+int
+TAO_Connection_Handler::make_idle (void)
+{
+ return
+ this->orb_core_->connection_cache ().make_idle (this->cache_map_entry_);
+}
+
+
+void
+TAO_Connection_Handler::remove_handle (ACE_HANDLE handle)
+{
+ TAO_Server_Strategy_Factory *f =
+ this->orb_core_->server_factory ();
+
+ /*if (f->activate_server_connections () == 0)
+ (void) this->orb_core_->remove_handle (handle);*/
+}
+
+
+int
+TAO_Connection_Handler::set_socket_option (ACE_SOCK &sock,
+ int snd_size,
+ int rcv_size)
+{
+#if !defined (ACE_LACKS_SOCKET_BUFSIZ)
+
+ if (sock.set_option (SOL_SOCKET,
+ SO_SNDBUF,
+ (void *) &snd_size,
+ sizeof (snd_size)) == -1
+ && errno != ENOTSUP)
+ return -1;
+ else if (sock.set_option (SOL_SOCKET,
+ SO_RCVBUF,
+ (void *) &rcv_size,
+ sizeof (int)) == -1
+ && errno != ENOTSUP)
+ return -1;
+#endif /* !ACE_LACKS_SOCKET_BUFSIZ */
+
+ (void) sock.enable (ACE_CLOEXEC);
+ // Set the close-on-exec flag for that file descriptor. If the
+ // operation fails we are out of luck (some platforms do not support
+ // it and return -1).
+
+ return 0;
+}
+
+int
+TAO_Connection_Handler::svc_i (void)
+{
+ int result = 0;
+
+ // Inheriting the ORB_Core tss stuff from the parent thread.
+ this->orb_core_->inherit_from_parent_thread (this->tss_resources_);
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("TAO (%P|%t) TAO_Connection_Handler::svc_i begin\n")));
+
+ // Here we simply synthesize the "typical" event loop one might find
+ // in a reactive handler, except that this can simply block waiting
+ // for input.
+
+ ACE_Time_Value *max_wait_time = 0;
+ ACE_Time_Value timeout;
+ ACE_Time_Value current_timeout;
+
+ if (this->orb_core_->thread_per_connection_timeout (timeout))
+ {
+ current_timeout = timeout;
+ max_wait_time = &current_timeout;
+ }
+
+ while (!this->orb_core_->has_shutdown ()
+ && result >= 0)
+ {
+ result = this->handle_input_i (ACE_INVALID_HANDLE, max_wait_time);
+
+ if (result == -1 && errno == ETIME)
+ {
+ // Ignore timeouts, they are only used to wake up and
+ // shutdown.
+ result = 0;
+
+ // Reset errno to make sure we don't trip over an old value
+ // of errno in case it is not reset when the recv() call
+ // fails if the socket has been closed.
+ errno = 0;
+ }
+
+ current_timeout = timeout;
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("TAO (%P|%t) TAO_Connection_Handler::svc_i - ")
+ ACE_TEXT ("loop <%d>\n"), current_timeout.msec ()));
+ }
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("TAO (%P|%t) TAO_Connection_Handler::svc_i end\n")));
+
+ return result;
+}
+
+ACE_Time_Value *
+TAO_Connection_Handler::handle_timeout_i (const ACE_Time_Value &,
+ const void *)
+{
+ //
+ // This method is called when buffering timer expires.
+ //
+
+
+ return 0;
+}
diff --git a/TAO/tao/Connection_Handler.h b/TAO/tao/Connection_Handler.h
new file mode 100644
index 00000000000..3ee33268792
--- /dev/null
+++ b/TAO/tao/Connection_Handler.h
@@ -0,0 +1,157 @@
+/* -*- C++ -*- */
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// tao
+//
+// = FILENAME
+// Connection_Handler.h
+//
+// = AUTHOR
+// Bala Natarajan <bala@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef TAO_CONNECTION_HANDLER_H
+#define TAO_CONNECTION_HANDLER_H
+#include "ace/pre.h"
+
+#include "ace/SOCK.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/Connection_Cache_Manager.h"
+
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning(push)
+#endif /* _MSC_VER >= 1200 */
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+class TAO_ORB_Core;
+class TAO_ORB_Core_TSS_Resources;
+class ACE_Reactor;
+class ACE_Event_Handler;
+
+class TAO_Connection_Handler
+{
+ // = TITLE
+ // TAO_Connection_Handler
+ //
+ // = DESCRIPTION
+ // This class is an abstraction for the connection handlers. The
+ // connections handler in every protocol can derive from this
+ // class as well as the ACE_Svc_Handler specialised for the
+ // right protocol. This way, most of the common code for the
+ // different protocls would be in this implementation. Further,
+ // this class wold be of immense use in storing the handlers in
+ // the Cache for TAO. This would help in purging entries which
+ // is generally accompanied by closing the open handles and
+ // deleting memory associated with the handlers.
+
+ // Note: This class has NOT abstracted the GIOP specific
+ // details. It is just to be safe so that, we can reuse this
+ // class for any messaging protocol underneath. This way we need
+ // not touch the Cache setup even when using other protocols (I
+ // mean messaging). BUT, I doubt whether this abstraction will
+ // satisfy the needs of other messaging protocols. (will not?).
+
+public:
+
+ TAO_Connection_Handler (void);
+ // Constructor
+
+ TAO_Connection_Handler (TAO_ORB_Core *orb_core);
+ // Constructor
+
+ virtual ~TAO_Connection_Handler (void);
+ // Destructor
+
+ void cache_map_entry (
+ TAO_Connection_Cache_Manager::HASH_MAP_ENTRY *entry);
+
+ TAO_Connection_Cache_Manager::HASH_MAP_ENTRY *cache_map_entry (void);
+ // Set/Get the Cache Map entry
+
+ int make_idle (void);
+ // Make ourselves ready for use
+
+ void incr_ref_count (void);
+ // Increment the reference count
+
+ void decr_ref_count (void);
+ // Decrement the reference count
+
+ CORBA::Boolean is_registered (void);
+ void is_registered (CORBA::Boolean);
+ // Get and set method for the flag that indicates whether the
+ // handler has been registered with the reactor or not.
+
+ virtual ACE_HANDLE fetch_handle (void) = 0;
+ // Get the underlying handle
+
+protected:
+
+ void remove_handle (ACE_HANDLE handle);
+ // Remove the handle from the ORB Core's handle set so that it
+ // isn't included in the set that is passed to the reactor upon
+ // ORB destruction.
+
+ TAO_ORB_Core *orb_core (void);
+ // Return our TAO_ORB_Core pointer
+
+ TAO_ORB_Core_TSS_Resources* tss_resources (void);
+ // Return our TSS Resources pointer
+
+ int set_socket_option (ACE_SOCK &sock,
+ int snd_size,
+ int rcv_size);
+ // Set options on the socket
+
+ int svc_i (void);
+ // This method is invoked from the svc () method of the Svc_Handler
+ // Object.
+
+ virtual int handle_input_i (ACE_HANDLE = ACE_INVALID_HANDLE,
+ ACE_Time_Value *max_wait_time = 0) = 0;
+ // Need to be implemented by the underlying protocol
+
+ ACE_Time_Value *handle_timeout_i (const ACE_Time_Value &,
+ const void *);
+ // Implementation of the method handle_timout () which would be
+ // called when the buffering timer expires.
+
+ int handle_cleanup_i (ACE_Reactor *reactor,
+ ACE_Event_Handler *handler);
+ // Implementation of the call handle_cleanup () in
+ // Service_Handler.
+
+private:
+
+ TAO_ORB_Core *orb_core_;
+ // Pointer to the TAO_ORB_Core
+
+ TAO_ORB_Core_TSS_Resources *tss_resources_;
+ // Cached tss resources of the ORB that activated this object.
+
+ u_long ref_count_;
+ // Reference count to the number of external references -- ie. the
+ // count of the number of places our references are being held.
+
+ TAO_Connection_Cache_Manager::HASH_MAP_ENTRY *cache_map_entry_;
+ // The cache map entry -- where we are in the Connection Cache
+
+ CORBA::Boolean is_registered_;
+ // Are we registered with the reactor?
+};
+
+#if defined (__ACE_INLINE__)
+#include "tao/Connection_Handler.inl"
+#endif /* __ACE_INLINE__ */
+
+#endif /*TAO_CONNECTION_HANDLER_H*/
diff --git a/TAO/tao/Connection_Handler.inl b/TAO/tao/Connection_Handler.inl
new file mode 100644
index 00000000000..7a4f44271f3
--- /dev/null
+++ b/TAO/tao/Connection_Handler.inl
@@ -0,0 +1,67 @@
+//* -*- C++ -*- */
+//$Id$
+
+ACE_INLINE
+TAO_Connection_Handler::TAO_Connection_Handler (void)
+ : orb_core_ (0),
+ tss_resources_ (0)
+{
+}
+
+ACE_INLINE
+TAO_Connection_Handler::~TAO_Connection_Handler (void)
+{
+}
+
+
+ACE_INLINE TAO_Connection_Cache_Manager::HASH_MAP_ENTRY *
+TAO_Connection_Handler::cache_map_entry (void)
+{
+ return this->cache_map_entry_;
+}
+
+ACE_INLINE void
+TAO_Connection_Handler::cache_map_entry (
+ TAO_Connection_Cache_Manager::HASH_MAP_ENTRY *entry)
+{
+ this->cache_map_entry_ = entry;
+}
+
+ACE_INLINE void
+TAO_Connection_Handler::incr_ref_count (void)
+{
+ this->ref_count_ ++;
+}
+
+ACE_INLINE void
+TAO_Connection_Handler::decr_ref_count (void)
+{
+ this->ref_count_ --;
+
+ if (this->ref_count_ == 0)
+ delete this;
+}
+
+ACE_INLINE CORBA::Boolean
+TAO_Connection_Handler::is_registered (void)
+{
+ return this->is_registered_;
+}
+
+ACE_INLINE void
+TAO_Connection_Handler::is_registered (CORBA::Boolean flag)
+{
+ this->is_registered_ = flag;
+}
+
+ACE_INLINE TAO_ORB_Core *
+TAO_Connection_Handler::orb_core (void)
+{
+ return this->orb_core_;
+}
+
+ACE_INLINE TAO_ORB_Core_TSS_Resources *
+TAO_Connection_Handler::tss_resources (void)
+{
+ return this->tss_resources_;
+}