summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a79
-rw-r--r--TAO/tao/Cache_Entries.cpp4
-rw-r--r--TAO/tao/Cache_Entries.h9
-rw-r--r--TAO/tao/Cache_Entries.inl18
-rw-r--r--TAO/tao/Connection_Purging_Strategy.h6
-rw-r--r--TAO/tao/LRU_Connection_Purging_Strategy.cpp6
-rw-r--r--TAO/tao/LRU_Connection_Purging_Strategy.h2
-rw-r--r--TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.cpp12
-rw-r--r--TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h2
-rw-r--r--TAO/tao/Strategies/LFU_Connection_Purging_Strategy.cpp6
-rw-r--r--TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h2
-rw-r--r--TAO/tao/Strategies/NULL_Connection_Purging_Strategy.cpp6
-rw-r--r--TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h2
-rw-r--r--TAO/tao/Transport.cpp60
-rw-r--r--TAO/tao/Transport.h20
-rw-r--r--TAO/tao/Transport.inl20
-rw-r--r--TAO/tao/Transport_Cache_Manager.cpp131
-rw-r--r--TAO/tao/Transport_Cache_Manager.h15
-rw-r--r--TAO/tao/Transport_Cache_Manager.inl49
19 files changed, 239 insertions, 210 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 31cff5e0ce4..f5df2724e12 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,43 +1,68 @@
+Wed May 23 09:04:35 2001 Chad Elliott <elliott_c@ociweb.com>
+
+ * Cache_Entries.cpp:
+ * Cache_Entries.h:
+ * Cache_Entries.inl:
+ * Connection_Purging_Strategy.h:
+ * LRU_Connection_Purging_Strategy.cpp:
+ * LRU_Connection_Purging_Strategy.h:
+ * Transport.cpp:
+ * Transport.h:
+ * Transport.inl:
+ * Transport_Cache_Manager.cpp:
+ * Transport_Cache_Manager.h:
+ * Transport_Cache_Manager.inl:
+ * Strategies/FIFO_Connection_Purging_Strategy.cpp:
+ * Strategies/FIFO_Connection_Purging_Strategy.h:
+ * Strategies/LFU_Connection_Purging_Strategy.cpp:
+ * Strategies/LFU_Connection_Purging_Strategy.h:
+ * Strategies/NULL_Connection_Purging_Strategy.cpp:
+ * Strategies/NULL_Connection_Purging_Strategy.h:
+
+ Performance enhancment and race condition fix for the connection
+ purging strategy change. This version has far less allocations and
+ locking in the main line of execution.
+
Wed May 23 8:23:20 2001 Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
- * orbsvcs/orbsvcs/AV/AVStreams_i.h:
- * orbsvcs/orbsvcs/AV/AVStreams_i.cpp:
- * orbsvcs/orbsvcs/AV/QoS_UDP.h:
- * orbsvcs/orbsvcs/AV/QoS_UDP.cpp:
- * orbsvcs/orbsvcs/AV/Transport.h:
- * orbsvcs/orbsvcs/AV/Transport.cpp:
+ * orbsvcs/orbsvcs/AV/AVStreams_i.h:
+ * orbsvcs/orbsvcs/AV/AVStreams_i.cpp:
+ * orbsvcs/orbsvcs/AV/QoS_UDP.h:
+ * orbsvcs/orbsvcs/AV/QoS_UDP.cpp:
+ * orbsvcs/orbsvcs/AV/Transport.h:
+ * orbsvcs/orbsvcs/AV/Transport.cpp:
- Provided a mechanism to modify QoS when there is a change in QoS. Also added the QoS negotiator mechanism as a means of notifying change in QoS.
+ Provided a mechanism to modify QoS when there is a change in QoS. Also added the QoS negotiator mechanism as a means of notifying change in QoS.
- * orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/sender.h:
- * orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/sender.cpp:
+ * orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/sender.h:
+ * orbsvcs/tests/AVStreams/Simple_Two_Stage_With_QoS/sender.cpp:
- Enhanced the test to test the notification and modification of change in QoS.
+ Enhanced the test to test the notification and modification of change in QoS.
Tue May 22 15:34:20 2001 Sharath R. Cholleti <sharath@cs.wustl.edu>
- * tao/tests/Oneway_Buffering/Oneway_Buffering_Admin.{h,cpp}:
- * tao/tests/Big_Oneways/Session.{h,cpp}:
- * tao/tests/AMI_Buffering/test_i.{h,cpp}:
- * tao/examples/Logging/Logger_i.{h,cpp}:
- * tao/examples/Buffered_Oneways/test_i.{h,cpp}:
- * tao/examples/Buffered_AMI/AMI_Buffering_Admin.{h,cpp}:
+ * tao/tests/Oneway_Buffering/Oneway_Buffering_Admin.{h,cpp}:
+ * tao/tests/Big_Oneways/Session.{h,cpp}:
+ * tao/tests/AMI_Buffering/test_i.{h,cpp}:
+ * tao/examples/Logging/Logger_i.{h,cpp}:
+ * tao/examples/Buffered_Oneways/test_i.{h,cpp}:
+ * tao/examples/Buffered_AMI/AMI_Buffering_Admin.{h,cpp}:
+
+ Fixed compile errors in Forte update 1.
- Fixed compile errors in Forte update 1.
-
Mon May 21 23:22:20 2001 Ossama Othman <ossama@uci.edu>
- * tao/TAO_Internal.cpp (open_services):
+ * tao/TAO_Internal.cpp (open_services):
- Fixed seg faults that occured due to brain damaged compilers
- that still treat string literals as "char *" instead of "const
- char *". This compiler problem caused the wrong (shallow)
- assignment operator to be used instead of the correct (deep)
- assignment operator. When the string sequence went out of
- scope, it attempted to delete a string that was not dynamically
- allocated. To get around deficiencies in such compilers,
- duplicate the string literal using CORBA::string_dup().
+ Fixed seg faults that occured due to brain damaged compilers
+ that still treat string literals as "char *" instead of "const
+ char *". This compiler problem caused the wrong (shallow)
+ assignment operator to be used instead of the correct (deep)
+ assignment operator. When the string sequence went out of
+ scope, it attempted to delete a string that was not dynamically
+ allocated. To get around deficiencies in such compilers,
+ duplicate the string literal using CORBA::string_dup().
Mon May 21 16:54:05 2001 Carlos O'Ryan <coryan@uci.edu>
diff --git a/TAO/tao/Cache_Entries.cpp b/TAO/tao/Cache_Entries.cpp
index f58a7dc2bca..9c7e17f0273 100644
--- a/TAO/tao/Cache_Entries.cpp
+++ b/TAO/tao/Cache_Entries.cpp
@@ -12,8 +12,7 @@ ACE_RCSID(tao, Cache_Entries, "$Id$")
TAO_Cache_IntId::TAO_Cache_IntId (TAO_Transport *transport)
: transport_ (TAO_Transport::_duplicate (transport)),
- recycle_state_ (ACE_RECYCLABLE_UNKNOWN),
- purging_order_ (0)
+ recycle_state_ (ACE_RECYCLABLE_UNKNOWN)
{
}
@@ -27,7 +26,6 @@ TAO_Cache_IntId::operator= (const TAO_Cache_IntId &rhs)
{
if (this != &rhs) {
this->recycle_state_ = rhs.recycle_state_;
- this->purging_order_ = rhs.purging_order_;
TAO_Transport* old_transport = this->transport_;
this->transport_ = TAO_Transport::_duplicate (rhs.transport_);
diff --git a/TAO/tao/Cache_Entries.h b/TAO/tao/Cache_Entries.h
index be74717c805..8c3477be95a 100644
--- a/TAO/tao/Cache_Entries.h
+++ b/TAO/tao/Cache_Entries.h
@@ -94,21 +94,12 @@ public:
*/
TAO_Transport *relinquish_transport (void);
- /// Return the order for the purging strategy
- unsigned long purging_order (void) const;
-
- /// Allow the purging strategy to set the order
- void purging_order(unsigned long value);
-
private:
/// The transport that needs to be cached.
TAO_Transport *transport_;
/// The state of the handle
ACE_Recyclable_State recycle_state_;
-
- /// Used by the LRU, LFU and FIFO Connection Purging Strategies
- unsigned long purging_order_;
};
diff --git a/TAO/tao/Cache_Entries.inl b/TAO/tao/Cache_Entries.inl
index 2ff9c520e1f..1e6bbc118fb 100644
--- a/TAO/tao/Cache_Entries.inl
+++ b/TAO/tao/Cache_Entries.inl
@@ -4,16 +4,14 @@
ACE_INLINE
TAO_Cache_IntId::TAO_Cache_IntId (void)
: transport_ (0),
- recycle_state_ (ACE_RECYCLABLE_UNKNOWN),
- purging_order_ (0)
+ recycle_state_ (ACE_RECYCLABLE_UNKNOWN)
{
}
ACE_INLINE
TAO_Cache_IntId::TAO_Cache_IntId (const TAO_Cache_IntId &rhs)
: transport_ (0),
- recycle_state_ (ACE_RECYCLABLE_UNKNOWN),
- purging_order_ (0)
+ recycle_state_ (ACE_RECYCLABLE_UNKNOWN)
{
*this = rhs;
}
@@ -63,18 +61,6 @@ TAO_Cache_IntId::relinquish_transport (void)
return val;
}
-ACE_INLINE unsigned long
-TAO_Cache_IntId::purging_order (void) const
-{
- return this->purging_order_;
-}
-
-ACE_INLINE void
-TAO_Cache_IntId::purging_order (unsigned long value)
-{
- this->purging_order_ = value;
-}
-
/*******************************************************/
ACE_INLINE
TAO_Cache_ExtId::TAO_Cache_ExtId (void)
diff --git a/TAO/tao/Connection_Purging_Strategy.h b/TAO/tao/Connection_Purging_Strategy.h
index 727735c75bd..6729434e0c7 100644
--- a/TAO/tao/Connection_Purging_Strategy.h
+++ b/TAO/tao/Connection_Purging_Strategy.h
@@ -12,14 +12,14 @@
#define TAO_PURGING_STRATEGY_H
#include "ace/pre.h"
-#include "corbafwd.h"
+#include "TAO_Export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
-class TAO_Cache_IntId;
+class TAO_Transport;
// ****************************************************************
@@ -45,7 +45,7 @@ public:
virtual int cache_maximum (void) const;
/// Sub-classes must implement these methods
- virtual void update_item (TAO_Cache_IntId& int_id) = 0;
+ virtual void update_item (TAO_Transport* transport) = 0;
private:
/// The maximum number of cach entries
diff --git a/TAO/tao/LRU_Connection_Purging_Strategy.cpp b/TAO/tao/LRU_Connection_Purging_Strategy.cpp
index 3cc795cfeec..f97016d0132 100644
--- a/TAO/tao/LRU_Connection_Purging_Strategy.cpp
+++ b/TAO/tao/LRU_Connection_Purging_Strategy.cpp
@@ -1,7 +1,7 @@
// $Id$
#include "LRU_Connection_Purging_Strategy.h"
-#include "Cache_Entries.h"
+#include "Transport.h"
ACE_RCSID(tao, LRU_Connection_Purging_Strategy, "$Id$")
@@ -19,8 +19,8 @@ TAO_LRU_Connection_Purging_Strategy::~TAO_LRU_Connection_Purging_Strategy (void)
void
-TAO_LRU_Connection_Purging_Strategy::update_item (TAO_Cache_IntId& int_id)
+TAO_LRU_Connection_Purging_Strategy::update_item (TAO_Transport* transport)
{
- int_id.purging_order (this->order_++);
+ transport->purging_order (this->order_++);
}
diff --git a/TAO/tao/LRU_Connection_Purging_Strategy.h b/TAO/tao/LRU_Connection_Purging_Strategy.h
index 0dd7a5efa3d..ab983148c02 100644
--- a/TAO/tao/LRU_Connection_Purging_Strategy.h
+++ b/TAO/tao/LRU_Connection_Purging_Strategy.h
@@ -41,7 +41,7 @@ public:
virtual ~TAO_LRU_Connection_Purging_Strategy (void);
/// Called when accessing an item from the cache
- virtual void update_item (TAO_Cache_IntId& int_id);
+ virtual void update_item (TAO_Transport* transport);
private:
/// The ordering information for each transport in the cache
diff --git a/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.cpp b/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.cpp
index 90155a43237..d1e9d6940b3 100644
--- a/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.cpp
+++ b/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.cpp
@@ -1,14 +1,16 @@
// $Id$
#include "FIFO_Connection_Purging_Strategy.h"
-#include "tao/Cache_Entries.h"
+#include "tao/Transport.h"
ACE_RCSID(tao, FIFO_Connection_Purging_Strategy, "$Id$")
TAO_FIFO_Connection_Purging_Strategy::TAO_FIFO_Connection_Purging_Strategy (
int cache_maximum)
: TAO_Connection_Purging_Strategy (cache_maximum),
- order_ (0)
+ // Initialized to 1 to insure that the transports purging_order
+ // is only 0 upon initialization.
+ order_ (1)
{
}
@@ -19,13 +21,13 @@ TAO_FIFO_Connection_Purging_Strategy::~TAO_FIFO_Connection_Purging_Strategy (voi
void
-TAO_FIFO_Connection_Purging_Strategy::update_item (TAO_Cache_IntId& int_id)
+TAO_FIFO_Connection_Purging_Strategy::update_item (TAO_Transport* transport)
{
// FIFO, so only update the purging order if this
// item has not been cached yet.
- if (int_id.purging_order () == 0)
+ if (transport->purging_order () == 0)
{
- int_id.purging_order (++(this->order_));
+ transport->purging_order (this->order_++);
}
}
diff --git a/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h b/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h
index 2ef03ec36b9..bf4ccffd314 100644
--- a/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h
+++ b/TAO/tao/Strategies/FIFO_Connection_Purging_Strategy.h
@@ -43,7 +43,7 @@ public:
virtual ~TAO_FIFO_Connection_Purging_Strategy (void);
/// Called when accessing an item from the cache
- virtual void update_item (TAO_Cache_IntId& int_id);
+ virtual void update_item (TAO_Transport* transport);
private:
/// The ordering information for each transport in the cache
diff --git a/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.cpp b/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.cpp
index 9280d34e176..961ba767c8e 100644
--- a/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.cpp
+++ b/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.cpp
@@ -1,7 +1,7 @@
// $Id$
#include "LFU_Connection_Purging_Strategy.h"
-#include "tao/Cache_Entries.h"
+#include "tao/Transport.h"
ACE_RCSID(tao, LFU_Connection_Purging_Strategy, "$Id$")
@@ -18,8 +18,8 @@ TAO_LFU_Connection_Purging_Strategy::~TAO_LFU_Connection_Purging_Strategy (void)
void
-TAO_LFU_Connection_Purging_Strategy::update_item (TAO_Cache_IntId& int_id)
+TAO_LFU_Connection_Purging_Strategy::update_item (TAO_Transport* transport)
{
- int_id.purging_order (int_id.purging_order () + 1);
+ transport->purging_order (transport->purging_order () + 1);
}
diff --git a/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h b/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h
index a5502d417a9..46ed221b08b 100644
--- a/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h
+++ b/TAO/tao/Strategies/LFU_Connection_Purging_Strategy.h
@@ -42,7 +42,7 @@ public:
virtual ~TAO_LFU_Connection_Purging_Strategy (void);
/// Called when accessing an item from the cache
- virtual void update_item (TAO_Cache_IntId& int_id);
+ virtual void update_item (TAO_Transport* transport);
};
#include "ace/post.h"
diff --git a/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.cpp b/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.cpp
index 44a5cd5336f..930c9c89053 100644
--- a/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.cpp
+++ b/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.cpp
@@ -1,7 +1,7 @@
// $Id$
#include "NULL_Connection_Purging_Strategy.h"
-#include "tao/Cache_Entries.h"
+#include "tao/Transport.h"
ACE_RCSID(tao, NULL_Connection_Purging_Strategy, "$Id$")
@@ -18,9 +18,9 @@ TAO_NULL_Connection_Purging_Strategy::~TAO_NULL_Connection_Purging_Strategy (voi
void
-TAO_NULL_Connection_Purging_Strategy::update_item (TAO_Cache_IntId& int_id)
+TAO_NULL_Connection_Purging_Strategy::update_item (TAO_Transport* transport)
{
- ACE_UNUSED_ARG (int_id);
+ ACE_UNUSED_ARG (transport);
}
diff --git a/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h b/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h
index 31a67c8bd22..bd7ffa27366 100644
--- a/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h
+++ b/TAO/tao/Strategies/NULL_Connection_Purging_Strategy.h
@@ -39,7 +39,7 @@ public:
virtual ~TAO_NULL_Connection_Purging_Strategy (void);
/// Does nothing.
- virtual void update_item (TAO_Cache_IntId& int_id);
+ virtual void update_item (TAO_Transport* transport);
/// Returns -1 to signify no maximum
virtual int cache_maximum (void) const;
diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp
index a7f0083aaf8..add1996ebb0 100644
--- a/TAO/tao/Transport.cpp
+++ b/TAO/tao/Transport.cpp
@@ -71,6 +71,7 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag,
, flush_timer_id_ (-1)
, transport_timer_ (this)
, id_ ((long) this)
+ , purging_order_ (0)
{
TAO_Client_Strategy_Factory *cf =
this->orb_core_->client_factory ();
@@ -108,6 +109,15 @@ TAO_Transport::~TAO_Transport (void)
tmp->destroy ();
}
+
+ // Avoid making the call if we can. This may be redundant, unless
+ // someone called handle_close() on the connection handler from
+ // outside the TAO_Transport.
+ if (this->cache_map_entry_ != 0)
+ {
+ this->orb_core_->transport_cache ()->purge_entry (
+ this->cache_map_entry_);
+ }
}
int
@@ -563,13 +573,6 @@ TAO_Transport::connection_handler_closing (void)
*this->handler_lock_));
this->transition_handler_state_i ();
-
- // Avoid making the call if we can
- if (this->cache_map_entry_ != 0)
- {
- this->orb_core_->transport_cache ()->purge_entry (
- this->cache_map_entry_);
- }
}
// Can't hold the lock while we release, b/c the release could
// invoke the destructor!
@@ -626,20 +629,41 @@ void
TAO_Transport::mark_invalid (void)
{
// @@ Do we need this method at all??
- this->orb_core_->transport_cache ()->mark_invalid (
- this->cache_map_entry_);
+ if (this->cache_map_entry_ != 0)
+ {
+ this->orb_core_->transport_cache ()->mark_invalid (
+ this->cache_map_entry_);
+ }
}
int
TAO_Transport::make_idle (void)
{
- return this->orb_core_->transport_cache ()->make_idle (
- this->cache_map_entry_);
+ if (this->cache_map_entry_ != 0)
+ {
+ return this->orb_core_->transport_cache ()->make_idle (
+ this->cache_map_entry_);
+ }
+ return -1;
}
void
TAO_Transport::close_connection (void)
{
+ this->close_connection_i ();
+
+ // Purge the entry
+ if (this->cache_map_entry_ != 0)
+ {
+ this->orb_core_->transport_cache ()->purge_entry (
+ this->cache_map_entry_);
+ }
+}
+
+
+void
+TAO_Transport::close_connection_i (void)
+{
ACE_Event_Handler *eh = 0;
{
ACE_MT (ACE_GUARD (ACE_Lock, guard, *this->handler_lock_));
@@ -672,20 +696,6 @@ TAO_Transport::close_connection (void)
(void) eh->handle_close (ACE_INVALID_HANDLE,
ACE_Event_Handler::ALL_EVENTS_MASK);
- // Purge the entry
- // @todo This is redundant, handle_close() eventually calls
- // this->connection_handler_closing(), that performs the same
- // work, for some reason they hold the mutex while they do
- // that work though.
- if (this->cache_map_entry_ != 0)
- {
- ACE_DEBUG ((LM_DEBUG,
- "TAO (%P|%t) - Transport::close_connection () - "
- "Is this redundant?\n"));
- this->orb_core_->transport_cache ()->purge_entry (
- this->cache_map_entry_);
- }
-
for (TAO_Queued_Message *i = this->head_; i != 0; i = i->next ())
{
i->connection_closed ();
diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h
index ea233a6cc07..2c848b93b50 100644
--- a/TAO/tao/Transport.h
+++ b/TAO/tao/Transport.h
@@ -271,8 +271,7 @@ public:
/// now.
virtual int idle_after_reply (void);
- /// Call the corresponding connection handler's <close>
- /// method.
+ /// Call the implementation method after obtaining the lock.
virtual void close_connection (void);
//@}
@@ -344,6 +343,12 @@ public:
/// Set the identifier for this transport instance.
void id (int id);
+ /// Return the order for the purging strategy.
+ unsigned long purging_order (void) const;
+
+ /// Allow the purging strategy to set the order.
+ void purging_order(unsigned long value);
+
protected:
/** @name Template methods
*
@@ -423,6 +428,14 @@ protected:
size_t len,
const ACE_Time_Value *timeout = 0) = 0;
+ /// This class needs priviledged access to
+ /// - close_connection_i()
+ friend class TAO_Transport_Cache_Manager;
+
+ /// Call the corresponding connection handler's <close>
+ /// method.
+ virtual void close_connection_i (void);
+
public:
/// This is a request for the transport object to write a
@@ -764,6 +777,9 @@ protected:
* might choose to set this to the handle for their connection.
*/
int id_;
+
+ /// Used by the LRU, LFU and FIFO Connection Purging Strategies.
+ unsigned long purging_order_;
};
#if defined (__ACE_INLINE__)
diff --git a/TAO/tao/Transport.inl b/TAO/tao/Transport.inl
index 48fac8f557c..b53fc80a7d7 100644
--- a/TAO/tao/Transport.inl
+++ b/TAO/tao/Transport.inl
@@ -37,12 +37,12 @@ TAO_Transport::bidirectional_flag (int flag)
this->bidirectional_flag_ = flag;
}
-/*ACE_INLINE TAO_Transport_Cache_Manager::HASH_MAP_ENTRY *
+ACE_INLINE TAO_Transport_Cache_Manager::HASH_MAP_ENTRY *
TAO_Transport::cache_map_entry (void)
{
return this->cache_map_entry_;
}
-*/
+
ACE_INLINE void
TAO_Transport::cache_map_entry (
@@ -77,3 +77,19 @@ TAO_Transport::check_event_handler_i (const char *caller)
}
return 0;
}
+
+ACE_INLINE unsigned long
+TAO_Transport::purging_order (void) const
+{
+ return this->purging_order_;
+}
+
+ACE_INLINE void
+TAO_Transport::purging_order (unsigned long value)
+{
+ // This should only be called by the Transport Cache Manager when
+ // it is holding it's lock.
+ // The transport should still be here since the cache manager still
+ // has a reference to it.
+ this->purging_order_ = value;
+}
diff --git a/TAO/tao/Transport_Cache_Manager.cpp b/TAO/tao/Transport_Cache_Manager.cpp
index 5aa2c4dc086..8056d2f26b1 100644
--- a/TAO/tao/Transport_Cache_Manager.cpp
+++ b/TAO/tao/Transport_Cache_Manager.cpp
@@ -66,14 +66,22 @@ TAO_Transport_Cache_Manager::open (TAO_ORB_Core *orb_core,
int
TAO_Transport_Cache_Manager::bind_i (TAO_Cache_ExtId &ext_id,
- TAO_Cache_IntId &int_id)
+ TAO_Cache_IntId &int_id)
{
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - ")
+ ACE_TEXT ("TAO_Transport_Cache_Manager")
+ ACE_TEXT ("::bind_i (0x%x, 0x%x)\n"),
+ ext_id.property (), int_id.transport ()));
+ }
+
// Get the entry too
HASH_MAP_ENTRY *entry = 0;
// Update the purging strategy information while we
// are holding our lock
- this->purging_strategy_->update_item (int_id);
+ this->purging_strategy_->update_item (int_id.transport ());
// When it comes for bind we know the transport is going to be busy
// and is marked for a partcular thread. So, mark it busy
@@ -143,11 +151,6 @@ TAO_Transport_Cache_Manager::find_transport (
int_id);
if (retval == 0)
{
- // Update the purging strategy information by unbinding
- // and then binding
- this->unbind (ext_id);
- this->bind (ext_id, int_id);
-
transport = int_id.relinquish_transport ();
}
@@ -241,9 +244,6 @@ TAO_Transport_Cache_Manager::unbind_i (const TAO_Cache_ExtId &key,
int
TAO_Transport_Cache_Manager::make_idle_i (HASH_MAP_ENTRY *&entry)
{
- if (entry == 0)
- return -1;
-
// 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;
@@ -390,32 +390,34 @@ TAO_Transport_Cache_Manager::cpscmp(const void* a, const void* b)
const HASH_MAP_ENTRY** left = (const HASH_MAP_ENTRY**)a;
const HASH_MAP_ENTRY** right = (const HASH_MAP_ENTRY**)b;
- if ((*left)->int_id_.purging_order () > (*right)->int_id_.purging_order ())
- return 1;
-
- if ((*left)->int_id_.purging_order () < (*right)->int_id_.purging_order ())
+ if ((*left)->int_id_.transport ()->purging_order () <
+ (*right)->int_id_.transport ()->purging_order ())
return -1;
+ if ((*left)->int_id_.transport ()->purging_order () >
+ (*right)->int_id_.transport ()->purging_order ())
+ return 1;
+
return 0;
}
#endif /* ACE_LACKS_QSORT */
void
-TAO_Transport_Cache_Manager::sort_set (HASH_MAP_ENTRY**& entries,
+TAO_Transport_Cache_Manager::sort_set (DESCRIPTOR_SET& entries,
int current_size)
{
#if defined (ACE_LACKS_QSORT)
// Use insertion sort if we don't have qsort
for(int i = 1; i < current_size; i++)
{
- if (entries[i]->int_id_.purging_order () <
- entries[i - 1]->int_id_.purging_order ())
+ if (entries[i]->int_id_.transport ()->purging_order () <
+ entries[i - 1]->int_id_.transport ()->purging_order ())
{
HASH_MAP_ENTRY* entry = entries[i];
for(int j = i; j > 0 &&
- entries[j - 1]->int_id_.purging_order () >
- entry->int_id_.purging_order (); j--)
+ entries[j - 1]->int_id_.transport ()->purging_order () >
+ entry->int_id_.transport ()->purging_order (); j--)
{
HASH_MAP_ENTRY* holder = entries[j];
entries[j] = entries[j - 1];
@@ -433,14 +435,16 @@ TAO_Transport_Cache_Manager::sort_set (HASH_MAP_ENTRY**& entries,
int
TAO_Transport_Cache_Manager::fill_set_i (DESCRIPTOR_SET& sorted_set)
{
- int amount = -1;
+ int current_size = 0;
int cache_maximum = this->purging_strategy_->cache_maximum ();
+ // set sorted_set to 0. This signifies nothing to purge.
+ sorted_set = 0;
+
// Do we need to worry about cache purging?
if (cache_maximum >= 0)
{
- int current_size = this->cache_map_.current_size ();
- amount = current_size - cache_maximum;
+ current_size = this->cache_map_.current_size ();
if (TAO_debug_level > 0)
{
@@ -450,44 +454,29 @@ TAO_Transport_Cache_Manager::fill_set_i (DESCRIPTOR_SET& sorted_set)
current_size, cache_maximum));
}
- if (amount >= 0)
+ if (current_size >= cache_maximum)
{
- // I could not use ACE_Array_Base<HASH_MAP_ENTRY*> because
- // the compiler kept complaining about HASH_MAP_ENTRY not having
- // a default construtor.
- HASH_MAP_ENTRY** entries;
- ACE_NEW_RETURN(entries, HASH_MAP_ENTRY*[current_size], 0);
- sorted_set.size (current_size);
-
- int i;
+ ACE_NEW_RETURN (sorted_set, HASH_MAP_ENTRY*[current_size], 0);
+
HASH_MAP_ITER iter = this->cache_map_.begin ();
- for (i = 0; i < current_size; i++)
+ for (int i = 0; i < current_size; i++)
{
- entries[i] = &(*iter);
+ sorted_set[i] = &(*iter);
iter++;
}
-
- this->sort_set (entries, current_size);
-
- for(i = 0; i < current_size; i++)
- {
- // The owner of the sorted_set array accepts responsibility
- // for deleting the memory allocated here.
- sorted_set[i] = entries[i]->ext_id_.property ()->duplicate ();
- }
-
- delete [] entries;
+ this->sort_set (sorted_set, current_size);
}
}
- return (amount >= 0);
+ return current_size;
}
void
-TAO_Transport_Cache_Manager::close_entries(DESCRIPTOR_SET& sorted_set)
+TAO_Transport_Cache_Manager::close_entries(DESCRIPTOR_SET& sorted_set,
+ int sorted_size)
{
- const int sorted_size = sorted_set.size ();
+ // Calculate the number of entries to purge
const int amount = (sorted_size * this->percent_) / 100;
if (TAO_debug_level > 0)
@@ -499,33 +488,37 @@ TAO_Transport_Cache_Manager::close_entries(DESCRIPTOR_SET& sorted_set)
}
int count = 0;
- for(int i = 0; i < sorted_size; i++)
+ for(int i = 0; count < amount && i < sorted_size; i++)
{
- TAO_Transport_Descriptor_Interface* prop = sorted_set[i];
- if (count < amount)
+ if (this->is_entry_idle(sorted_set[i]))
{
- // Compose the ExternId
- TAO_Cache_ExtId ext_id (prop);
- TAO_Cache_IntId int_id;
-
- if (this->find (ext_id, int_id) == 0)
+ TAO_Transport* transport = sorted_set[i]->int_id_.transport ();
+ if (TAO_debug_level > 0)
{
- TAO_Transport* transport = int_id.relinquish_transport ();
- if (TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - ")
- ACE_TEXT ("Idle transport found in ")
- ACE_TEXT ("cache: 0x%x\n"),
- transport));
- }
-
- // Eventually calls purge_entry() on us.
- transport->close_connection ();
- count++;
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - ")
+ ACE_TEXT ("Idle transport found in ")
+ ACE_TEXT ("cache: 0x%x\n"),
+ transport));
}
+
+ // We need to save the cache_map_entry before we
+ // set it to zero, so we can call purge_entry_i()
+ // after we call close_connection_i().
+ HASH_MAP_ENTRY* entry = transport->cache_map_entry ();
+
+ // This is a bit ugly, but we must do this to
+ // avoid taking and giving locks inside this loop.
+ transport->cache_map_entry (0);
+ transport->close_connection_i ();
+ this->purge_entry_i (entry);
+
+ // Count this as a successful purged entry
+ count++;
}
- delete prop;
}
+
+ delete [] sorted_set;
+ sorted_set = 0;
}
@@ -545,7 +538,6 @@ template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_Cache_ExtId, TAO_Cache_IntId
template class ACE_Unbounded_Set<ACE_Event_Handler*>;
template class ACE_Unbounded_Set_Iterator<ACE_Event_Handler*>;
template class ACE_Node<ACE_Event_Handler*>;
-template class ACE_Array_Base<TAO_Transport_Descriptor_Interface*>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
@@ -563,6 +555,5 @@ template class ACE_Array_Base<TAO_Transport_Descriptor_Interface*>;
#pragma instantiate ACE_Unbounded_Set<ACE_Event_Handler*>
#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Event_Handler*>
#pragma instantiate ACE_Node<ACE_Event_Handler*>
-#pragma instantiate ACE_Array_Base<TAO_Transport_Descriptor_Interface*>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/tao/Transport_Cache_Manager.h b/TAO/tao/Transport_Cache_Manager.h
index 58292a4c916..92a73ef2330 100644
--- a/TAO/tao/Transport_Cache_Manager.h
+++ b/TAO/tao/Transport_Cache_Manager.h
@@ -16,7 +16,6 @@
#include "ace/pre.h"
#include "ace/Hash_Map_Manager_T.h"
-#include "ace/Array_Base.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
#define ACE_LACKS_PRAGMA_ONCE
@@ -24,7 +23,8 @@
#include "tao/TAO_Export.h"
#include "tao/Cache_Entries.h"
-#include "tao/debug.h"
+
+#include "tao/Connection_Purging_Strategy.h"
#if defined(_MSC_VER)
#if (_MSC_VER >= 1200)
@@ -36,7 +36,7 @@
class TAO_ORB_Core;
class ACE_Handle_Set;
class TAO_Resource_Factory;
-class TAO_Connection_Purging_Strategy;
+
typedef ACE_Unbounded_Set<ACE_Event_Handler*> TAO_EventHandlerSet;
typedef ACE_Unbounded_Set_Iterator<ACE_Event_Handler*>
@@ -220,19 +220,18 @@ private:
static int cpscmp(const void* a, const void* b);
#endif
- typedef ACE_Array_Base<TAO_Transport_Descriptor_Interface*>
- DESCRIPTOR_SET;
+ typedef HASH_MAP_ENTRY** DESCRIPTOR_SET;
/// Sort the list of entries
- void sort_set (HASH_MAP_ENTRY**& entries, int size);
+ void sort_set (DESCRIPTOR_SET& entries, int size);
/// Fill sorted_set in with the TAO_Transport_Descriptor_Interface's in
/// a sorted order.
- virtual int fill_set_i (DESCRIPTOR_SET& sorted_set);
+ int fill_set_i (DESCRIPTOR_SET& sorted_set);
/// Look through the sorted set and close the connection on
/// the required number of items in the set.
- void close_entries (DESCRIPTOR_SET& sorted_set);
+ void close_entries (DESCRIPTOR_SET& sorted_set, int size);
private:
/// The percentage of the cache to purge at one time
diff --git a/TAO/tao/Transport_Cache_Manager.inl b/TAO/tao/Transport_Cache_Manager.inl
index 8cdfd10519a..0840e7961c9 100644
--- a/TAO/tao/Transport_Cache_Manager.inl
+++ b/TAO/tao/Transport_Cache_Manager.inl
@@ -24,24 +24,24 @@ TAO_Transport_Cache_Manager::find (const TAO_Cache_ExtId &key,
*this->cache_lock_,
-1));
- return this->find_i (key,
- value);
+ int status = this->find_i (key,
+ value);
+
+ if (status == 0)
+ {
+ // Update the purging strategy information while we
+ // are holding our lock
+ this->purging_strategy_->update_item (value.transport ());
+ }
+ return status;
}
ACE_INLINE int
TAO_Transport_Cache_Manager::cache_transport (
- TAO_Transport_Descriptor_Interface *prop,
- TAO_Transport *transport)
+ TAO_Transport_Descriptor_Interface *prop,
+ TAO_Transport *transport)
{
- if (TAO_debug_level > 0)
- {
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO (%P|%t) - ")
- ACE_TEXT ("TAO_Transport_Cache_Manager")
- ACE_TEXT ("::cache_transport (0x%x, 0x%x)\n"),
- prop, transport));
- }
-
// Compose the ExternId & Intid
TAO_Cache_ExtId ext_id (prop);
TAO_Cache_IntId int_id (transport);
@@ -53,7 +53,7 @@ TAO_Transport_Cache_Manager::cache_transport (
ACE_INLINE int
TAO_Transport_Cache_Manager::rebind (const TAO_Cache_ExtId &key,
- const TAO_Cache_IntId &value)
+ const TAO_Cache_IntId &value)
{
ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
guard,
@@ -92,22 +92,17 @@ TAO_Transport_Cache_Manager::unbind (const TAO_Cache_ExtId &key,
ACE_INLINE int
TAO_Transport_Cache_Manager::purge (void)
{
- int need_to_purge = 0;
- DESCRIPTOR_SET sorted_set;
-
- // We must use a small scope, since we can't call close_entries()
- // if we are holding the lock.
- {
- ACE_MT (ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->cache_lock_, 0));
- need_to_purge = this->fill_set_i (sorted_set);
- }
-
- // Only call close_entries () if need_to_purge. It takes control of
- // sorted_set and cleans up any allocated memory. If !need_to_purge,
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->cache_lock_, 0));
+
+ DESCRIPTOR_SET sorted_set = 0;
+ int size = this->fill_set_i (sorted_set);
+
+ // Only call close_entries () if sorted_set != 0. It takes control of
+ // sorted_set and cleans up any allocated memory. If sorted_set == 0,
// then there is nothing to de-allocate.
- if (need_to_purge)
+ if (sorted_set != 0)
{
- this->close_entries (sorted_set);
+ this->close_entries (sorted_set, size);
}
return 0;