summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2014-05-29 17:22:40 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2014-05-29 17:22:40 +0000
commiteb776073fbaac208f28ace6c493a1d46c9931709 (patch)
tree1fb0ccb703912abe6f28ba7d60bc3b111ab9f314
parent55f8eecdfdbd09064793a9499600206f277d1291 (diff)
downloadATCD-eb776073fbaac208f28ace6c493a1d46c9931709.tar.gz
Thu May 29 17:01:45 UTC 2014 Phil Mesnier <mesnier_p@ociweb.com>
* orbsvcs/FT_Naming_Service/README: minor cleanup. * orbsvcs/orbsvcs/FT_Naming_Serv.mpc: added FT_Random files. * orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h: * orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp: removed the redundant and confusing lock reference passed separately through the constructor and replaced it with an accessor method on the context being iterated. This also was necessary by the change to RW locking for scalability improvement. * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h: * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp: * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp: * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.h: * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.cpp: * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp: Optimize the FT/LB performance by only taking a lock when necessary. The underling context object synchronizes access to the context map, and the Round Robin strategy object synchronizes access to the index. Added a Random strategy that does not need a lock. * orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h: * orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp: * orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp: * orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h: * orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp: * orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp: Replaced the Recursive locking with RW. There was no need for recursive locking, even in the face of nested and possibly cyclic compound names. Given that most operations on the name service are read-only resolves, using RW locking allows for threadsafe concurrent access. In the case of Storable contexts, the backing file is now checked to see if a reload is necessary before grabbing a lock and loading from the file. * tao/Storable_File_Guard.h: * tao/Storable_File_Guard.cpp: Split the init method implementation into two parts that can be called separately. This allows for initialization of the related file object without holding a lock, then aquiring a lock only if loading from the file is necessary. Default behavior is unchanged.
-rw-r--r--TAO/ChangeLog46
-rw-r--r--TAO/orbsvcs/FT_Naming_Service/README3
-rw-r--r--TAO/orbsvcs/orbsvcs/FT_Naming_Serv.mpc2
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp29
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h8
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp19
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h14
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp6
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.cpp53
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.h77
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp6
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp63
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h4
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp45
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp674
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h18
-rw-r--r--TAO/orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp19
-rw-r--r--TAO/tao/Storable_File_Guard.cpp40
-rw-r--r--TAO/tao/Storable_File_Guard.h10
19 files changed, 531 insertions, 605 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 01827e34d81..659ddb8d150 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,49 @@
+Thu May 29 17:01:45 UTC 2014 Phil Mesnier <mesnier_p@ociweb.com>
+
+ * orbsvcs/FT_Naming_Service/README:
+ minor cleanup.
+
+ * orbsvcs/orbsvcs/FT_Naming_Serv.mpc:
+ added FT_Random files.
+
+ * orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h:
+ * orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp:
+ removed the redundant and confusing lock reference passed separately
+ through the constructor and replaced it with an accessor method on the
+ context being iterated. This also was necessary by the change to RW
+ locking for scalability improvement.
+
+ * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h:
+ * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp:
+ * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp:
+ * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.h:
+ * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.cpp:
+ * orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp:
+ Optimize the FT/LB performance by only taking a lock when necessary. The
+ underling context object synchronizes access to the context map, and the
+ Round Robin strategy object synchronizes access to the index. Added a
+ Random strategy that does not need a lock.
+
+ * orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h:
+ * orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp:
+ * orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp:
+ * orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h:
+ * orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp:
+ * orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp:
+ Replaced the Recursive locking with RW. There was no need for recursive
+ locking, even in the face of nested and possibly cyclic compound names.
+ Given that most operations on the name service are read-only resolves,
+ using RW locking allows for threadsafe concurrent access. In the case of
+ Storable contexts, the backing file is now checked to see if a reload is
+ necessary before grabbing a lock and loading from the file.
+
+ * tao/Storable_File_Guard.h:
+ * tao/Storable_File_Guard.cpp:
+ Split the init method implementation into two parts that can be
+ called separately. This allows for initialization of the related
+ file object without holding a lock, then aquiring a lock only if
+ loading from the file is necessary. Default behavior is unchanged.
+
Mon May 19 20:25:18 UTC 2014 Phil Mesnier <mesnier_p@ociweb.com>
* tests/Dynamic_TP/POA_Loader/Dynamic_TP_POA_Test_Dynamic/run_test.pl:
diff --git a/TAO/orbsvcs/FT_Naming_Service/README b/TAO/orbsvcs/FT_Naming_Service/README
index 392e01a24b0..a1cc6dcef69 100644
--- a/TAO/orbsvcs/FT_Naming_Service/README
+++ b/TAO/orbsvcs/FT_Naming_Service/README
@@ -22,6 +22,7 @@ How to Run the TAO FT Naming Service
[-g ft_naming_manager_ior_file]
[-o this_servers_object_ref_ior_file]
[-r directory_for_naming_context_replication]
+ [-u directory_for_flat_file_persistence]
[-v directory_for_object_group_replication]
[-s context_size]
[-z time]
@@ -132,7 +133,7 @@ How to Run the TAO FT Naming Service
reference information in a file per context. Each context file
is placed in the directory specified. This option can be used
when running the FT Naming Service standalone - without
- fault tolerance/redundancyl.
+ fault tolerance/redundancy.
-v directory
Use redundant flat-file persistence for naming contexts that
diff --git a/TAO/orbsvcs/orbsvcs/FT_Naming_Serv.mpc b/TAO/orbsvcs/orbsvcs/FT_Naming_Serv.mpc
index e8a0a2d15cc..044248938b4 100644
--- a/TAO/orbsvcs/orbsvcs/FT_Naming_Serv.mpc
+++ b/TAO/orbsvcs/orbsvcs/FT_Naming_Serv.mpc
@@ -16,6 +16,7 @@ project (FT_Naming_Serv) : orbsvcslib, orbsvcs_output, ftnaming, ftnaming_replic
Naming/FaultTolerant/FT_Naming_Server.cpp
Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp
Naming/FaultTolerant/FT_Persistent_Naming_Context_Factory.cpp
+ Naming/FaultTolerant/FT_Random.cpp
Naming/FaultTolerant/FT_Round_Robin.cpp
Naming/FaultTolerant/FT_Storable_Naming_Context.cpp
Naming/FaultTolerant/FT_Storable_Naming_Context_Factory.cpp
@@ -29,6 +30,7 @@ project (FT_Naming_Serv) : orbsvcslib, orbsvcs_output, ftnaming, ftnaming_replic
Naming/FaultTolerant/FT_Naming_Server.h
Naming/FaultTolerant/FT_Persistent_Naming_Context.h
Naming/FaultTolerant/FT_Persistent_Naming_Context_Factory.h
+ Naming/FaultTolerant/FT_Random.h
Naming/FaultTolerant/FT_Round_Robin.h
Naming/FaultTolerant/FT_Storable_Naming_Context.h
Naming/FaultTolerant/FT_Storable_Naming_Context_Factory.h
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp b/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp
index 13b38644e22..2c6c4cc05c1 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.cpp
@@ -15,12 +15,10 @@ template <class ITERATOR, class TABLE_ENTRY>
TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::TAO_Bindings_Iterator (
TAO_Hash_Naming_Context *context,
ITERATOR *hash_iter,
- PortableServer::POA_ptr poa,
- TAO_SYNCH_RECURSIVE_MUTEX &lock)
+ PortableServer::POA_ptr poa)
: destroyed_ (false),
context_ (context),
hash_iter_ (hash_iter),
- lock_ (lock),
poa_ (PortableServer::POA::_duplicate (poa))
{
@@ -57,11 +55,6 @@ TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::next_one (
b = binding;
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
// Check to make sure this object is still valid.
if (this->destroyed_)
throw CORBA::OBJECT_NOT_EXIST ();
@@ -84,6 +77,11 @@ TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::next_one (
}
else
{
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX,
+ ace_mon,
+ this->context_->lock (),
+ CORBA::INTERNAL ());
+
// Return a binding.
TABLE_ENTRY *hash_entry = 0;
hash_iter_->next (hash_entry);
@@ -106,11 +104,6 @@ TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::next_n (
ACE_NEW_THROW_EX (bl,
CosNaming::BindingList (0),
CORBA::NO_MEMORY ());
- // Obtain the lock.
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
// Check to make sure this object is still valid.
if (this->destroyed_)
@@ -134,6 +127,11 @@ TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::next_n (
return 0;
else
{
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX,
+ ace_mon,
+ this->context_->lock (),
+ CORBA::INTERNAL ());
+
// Initially assume that the iterator has the requested number of
// bindings.
bl->length (how_many);
@@ -163,11 +161,6 @@ TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::next_n (
template <class ITERATOR, class TABLE_ENTRY> void
TAO_Bindings_Iterator<ITERATOR, TABLE_ENTRY>::destroy (void)
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
// Check to make sure this object is still valid.
if (this->destroyed_)
throw CORBA::OBJECT_NOT_EXIST ();
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h b/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h
index 7e85834f857..4b1b7e7a6c8 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/Bindings_Iterator_T.h
@@ -59,9 +59,7 @@ public:
*/
TAO_Bindings_Iterator (TAO_Hash_Naming_Context *context,
ITERATOR *hash_iter,
- PortableServer::POA_ptr poa,
- TAO_SYNCH_RECURSIVE_MUTEX &lock);
-
+ PortableServer::POA_ptr poa);
/// Destructor.
~TAO_Bindings_Iterator (void);
@@ -117,10 +115,6 @@ private:
/// A pointer to the hash map iterator.
ITERATOR *hash_iter_;
- /// Lock passed on from Naming Context to serialize access to the
- /// internal data structure.
- TAO_SYNCH_RECURSIVE_MUTEX &lock_;
-
/// Implement a different _default_POA().
PortableServer::POA_var poa_;
};
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp
index a532150974d..ff56e1c3fbb 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.cpp
@@ -100,8 +100,8 @@ TAO_FT_Naming_Manager::create_object_group (
throw PortableGroup::ObjectNotCreated ();
}
- /// Currently only FT_Naming::ROUND_ROBIN is supported
- if (lb_strategy != FT_Naming::ROUND_ROBIN)
+ if (lb_strategy != FT_Naming::ROUND_ROBIN &&
+ lb_strategy != FT_Naming::RANDOM)
{
throw PortableGroup::ObjectNotCreated ();
}
@@ -737,10 +737,6 @@ void
TAO_FT_Naming_Manager::initialize (CORBA::ORB_ptr orb,
PortableServer::POA_ptr naming_mgr_poa)
{
- ACE_GUARD (TAO_SYNCH_MUTEX,
- guard,
- this->lock_);
-
// Initialize the components used to implement the PortableGroup interfaces
this->factory_registry_.init (orb);
PortableGroup::FactoryRegistry_var factory_ref =
@@ -759,19 +755,13 @@ TAO_FT_Naming_Manager::next_member (PortableGroup::ObjectGroup_ptr object_group)
{
ORBSVCS_ERROR (
(LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) - TAO_FT_Naming_Manager::add_member")
+ ACE_TEXT ("TAO (%P|%t) - TAO_FT_Naming_Manager::next_member ")
ACE_TEXT ("Null object group provided.\n")
));
}
throw PortableGroup::ObjectGroupNotFound ();
}
- ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
- monitor,
- this->lock_,
- CORBA::Object::_nil ()
- );
-
ACE_Auto_Ptr<PortableGroup::Properties> props (
this->get_properties (object_group));
PortableGroup::Value value;
@@ -806,6 +796,9 @@ TAO_FT_Naming_Manager::next_member (PortableGroup::ObjectGroup_ptr object_group)
case ::FT_Naming::ROUND_ROBIN:
result = this->round_robin_.next_location (object_group, this, next_location);
break;
+ case ::FT_Naming::RANDOM:
+ result = this->random_.next_location (object_group, this, next_location);
+ break;
default:
ORBSVCS_ERROR ((LM_ERROR,
ACE_TEXT ("TAO (%P|%t) - TAO_FT_Naming_Manager::next_location: ")
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h
index 453a2826831..511d33b093c 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h
@@ -23,6 +23,7 @@
#include "orbsvcs/PortableGroup/PG_FactoryRegistry.h"
#include "orbsvcs/PortableGroup/PG_Properties_Support.h"
#include "orbsvcs/Naming/FaultTolerant/FT_PG_Group_Factory.h"
+#include "orbsvcs/Naming/FaultTolerant/FT_Random.h"
#include "orbsvcs/Naming/FaultTolerant/FT_Round_Robin.h"
#include "tao/Condition.h"
@@ -299,10 +300,6 @@ private:
/// the name parameter.
bool group_name (PortableGroup::ObjectGroup_ptr group, char*& name);
- /// Mutex that provides synchronization for the TAO_FT_Naming_Manager's
- /// state.
- TAO_SYNCH_MUTEX lock_;
-
/// an object that manages default and type_id related properties
TAO::PG_Properties_Support properties_support_;
@@ -315,13 +312,15 @@ private:
/**
* @name Built-in load balancing strategy implementations
*
- * "Built-in" load balancing strategies. Currently only RoundRobin
- * is supported.
+ * "Built-in" load balancing strategies. Currently RoundRobin
+ * and Random are supported.
*/
//@{
/// The "RoundRobin" load balancing strategy.
TAO_FT_Round_Robin round_robin_;
+ /// The "Random" load balancing strategy.
+ TAO_FT_Random random_;
//@}
/// Cached instance of the Property name
@@ -330,9 +329,6 @@ private:
PortableGroup::Name object_group_property_name_;
- TAO_SYNCH_MUTEX validate_lock_;
- TAO_Condition<TAO_SYNCH_MUTEX> validate_condition_;
-
bool shutdown_;
};
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp
index 0294b7c7c9f..989bf39c3d5 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Persistent_Naming_Context.cpp
@@ -54,11 +54,7 @@ TAO_FT_Persistent_Naming_Context::resolve (const CosNaming::Name& n)
// Invoke the base class resolve operation to acquire the object at the
// specified compound name.
// Any exceptions should flow back to client.
- CORBA::Object_var resolved_ref =
- TAO_Persistent_Naming_Context::resolve(n);
-
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_,
- CORBA::INTERNAL ());
+ CORBA::Object_var resolved_ref = TAO_Persistent_Naming_Context::resolve(n);
// Get the locations of the object group members and we will use them to
// do the load balancing
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.cpp
new file mode 100644
index 00000000000..9b267d15590
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.cpp
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+// $Id$
+
+#include "orbsvcs/Naming/FaultTolerant/FT_Random.h"
+#include "orbsvcs/Naming/FaultTolerant/FT_Naming_Manager.h"
+
+#include "orbsvcs/PortableGroup/PG_conf.h"
+
+#include "tao/debug.h"
+#include "tao/ORB_Constants.h"
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+TAO_FT_Random::TAO_FT_Random (void)
+{
+}
+
+TAO_FT_Random::~TAO_FT_Random (void)
+{
+}
+
+bool
+TAO_FT_Random::next_location (
+ PortableGroup::ObjectGroup_ptr object_group,
+ TAO_FT_Naming_Manager *naming_manager,
+ PortableGroup::Location& location)
+{
+ PortableGroup::Locations_var locations =
+ naming_manager->locations_of_members (object_group);
+
+ const CORBA::ULong len = locations->length ();
+
+ // No locations exist, so we can't get the next one
+ if (len == 0)
+ return false;
+
+ CORBA::ULong i = 0;
+ if (len > 1)
+ {
+ // Prevent integer arithmetic overflow.
+ double flen = static_cast<double> (len);
+ do
+ {
+ i = static_cast<CORBA::ULong> (flen * ACE_OS::rand () / (RAND_MAX + 1.0));
+ }
+ while (i == len);
+ }
+ location = locations[i];
+ return true;
+}
+
+
+TAO_END_VERSIONED_NAMESPACE_DECL
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.h b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.h
new file mode 100644
index 00000000000..b4e8cc9d1f4
--- /dev/null
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Random.h
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file FT_Random.h
+ *
+ * $Id$
+ *
+ * @author Kevin Stanley <stanleyk@ociweb.com>
+ */
+//=============================================================================
+
+
+#ifndef FT_RANDOM_H
+#define FT_RANDOM_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Null_Mutex.h"
+
+# if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+# endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "orbsvcs/Naming/FaultTolerant/FT_Location_Index_Map.h"
+
+
+#include "orbsvcs/CosLoadBalancingS.h"
+#include "ace/Vector_T.h"
+#include "orbsvcs/Naming/FaultTolerant/ftnaming_export.h"
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+class TAO_FT_Naming_Manager;
+
+/**
+ * @class TAO_LB_Random_Strategy
+ *
+ * @brief "Random" load balancing strategy used by the
+ * TAO_FT_Naming_Service.
+ *
+ * This load balancing strategy is designed to select an object group
+ * member residing at the next location from an object group managed
+ * by a specific Naming Manager. It selects an object from the object
+ * group in the order in which they are stored.
+ */
+class TAO_FtNaming_Export TAO_FT_Random
+{
+public:
+
+ /// Constructor.
+ TAO_FT_Random (void);
+
+ /// Destructor
+ virtual ~TAO_FT_Random (void);
+
+ /// This function obtains the next object's location as it is bound
+ /// within the object group.
+ /// @param naming_manager The TAO_FT_Naming_Manager which houses the
+ /// object groups.
+ /// @param location The resulting location
+ /// @param object_group The object group from which the object is to
+ /// be selected
+ /// @return False on error. Returns true if a valid object can
+ /// be selected using the Random load balancing strategy.
+ virtual bool next_location (
+ PortableGroup::ObjectGroup_ptr object_group,
+ TAO_FT_Naming_Manager *naming_manager,
+ PortableGroup::Location& location);
+
+};
+
+TAO_END_VERSIONED_NAMESPACE_DECL
+
+#include /**/ "ace/post.h"
+
+#endif /* FT_RANDOM_H */
diff --git a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp
index eab29ba788b..01b0605fadc 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/FaultTolerant/FT_Storable_Naming_Context.cpp
@@ -58,11 +58,7 @@ TAO_FT_Storable_Naming_Context::resolve (const CosNaming::Name& n)
{
// Invoke the base class resolve operation to acquire the object at the
// specified compound name. Any exceptions should flow back to client.
- CORBA::Object_var resolved_ref =
- TAO_Storable_Naming_Context::resolve(n);
-
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_,
- CORBA::INTERNAL ());
+ CORBA::Object_var resolved_ref = TAO_Storable_Naming_Context::resolve(n);
try {
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp
index de3c6d1c4f5..43cbdf3a7fc 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.cpp
@@ -40,6 +40,12 @@ TAO_Hash_Naming_Context::~TAO_Hash_Naming_Context (void)
delete context_;
}
+TAO_SYNCH_RW_MUTEX&
+TAO_Hash_Naming_Context::lock (void)
+{
+ return this->lock_;
+}
+
PortableServer::POA_ptr
TAO_Hash_Naming_Context::_default_POA (void)
{
@@ -49,7 +55,6 @@ TAO_Hash_Naming_Context::_default_POA (void)
CosNaming::NamingContext_ptr
TAO_Hash_Naming_Context::get_context (const CosNaming::Name &name)
{
- // Naming context we will return.
CosNaming::NamingContext_var result =
CosNaming::NamingContext::_nil ();
@@ -62,8 +67,7 @@ TAO_Hash_Naming_Context::get_context (const CosNaming::Name &name)
const_cast<CosNaming::NameComponent*> (name.get_buffer ()));
try
{
- // Resolve the name.
- CORBA::Object_var context = resolve (comp_name);
+ CORBA::Object_var context = this->resolve (comp_name);
// Try narrowing object reference to the NamingContext type.
result = CosNaming::NamingContext::_narrow (context.in ());
@@ -132,9 +136,9 @@ TAO_Hash_Naming_Context::bind (const CosNaming::Name& n, CORBA::Object_ptr obj)
// If we received a simple name, we need to bind it in this context.
else
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon, this->lock_,
- CORBA::INTERNAL ());
+ ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX,
+ ace_mon, this->lock_,
+ CORBA::INTERNAL ());
// Try binding the name.
int result = this->context_->bind (n[0].id,
@@ -171,7 +175,7 @@ TAO_Hash_Naming_Context::rebind (const CosNaming::Name& n,
// on target context.
if (name_len > 1)
{
- CosNaming::NamingContext_var context = get_context (n);
+ CosNaming::NamingContext_var context = this->get_context (n);
CosNaming::Name simple_name;
simple_name.length (1);
@@ -190,9 +194,9 @@ TAO_Hash_Naming_Context::rebind (const CosNaming::Name& n,
// If we received a simple name, we need to rebind it in this
// context.
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
int result = this->context_->rebind (n[0].id,
n[0].kind,
@@ -233,7 +237,7 @@ TAO_Hash_Naming_Context::bind_context (const CosNaming::Name &n,
// target context.
if (name_len > 1)
{
- CosNaming::NamingContext_var context = get_context (n);
+ CosNaming::NamingContext_var context = this->get_context (n);
CosNaming::Name simple_name;
simple_name.length (1);
@@ -251,9 +255,9 @@ TAO_Hash_Naming_Context::bind_context (const CosNaming::Name &n,
// If we received a simple name, we need to bind it in this context.
else
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
// Try binding the name.
int result = this->context_->bind (n[0].id,
@@ -290,8 +294,7 @@ TAO_Hash_Naming_Context::rebind_context (const CosNaming::Name &n,
// on target context.
if (name_len > 1)
{
- CosNaming::NamingContext_var context =
- get_context (n);
+ CosNaming::NamingContext_var context = this->get_context (n);
CosNaming::Name simple_name;
simple_name.length (1);
@@ -310,9 +313,9 @@ TAO_Hash_Naming_Context::rebind_context (const CosNaming::Name &n,
// If we received a simple name, we need to rebind it in this
// context.
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
int result = this->context_->rebind (n[0].id,
n[0].kind,
@@ -353,8 +356,8 @@ TAO_Hash_Naming_Context::resolve (const CosNaming::Name& n)
CORBA::Object_var result;
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_,
- CORBA::INTERNAL ());
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon, this->lock_,
+ CORBA::INTERNAL ());
if (this->context_->find (n[0].id,
n[0].kind,
result.out (),
@@ -416,9 +419,9 @@ TAO_Hash_Naming_Context::resolve (const CosNaming::Name& n)
}
else
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
if (this->context_->find (n[0].id,
n[0].kind,
@@ -453,8 +456,7 @@ TAO_Hash_Naming_Context::unbind (const CosNaming::Name& n)
// on target context.
if (name_len > 1)
{
- CosNaming::NamingContext_var context =
- get_context (n);
+ CosNaming::NamingContext_var context = this->get_context (n);
CosNaming::Name simple_name;
simple_name.length (1);
@@ -473,9 +475,9 @@ TAO_Hash_Naming_Context::unbind (const CosNaming::Name& n)
// context.
else
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ ACE_WRITE_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
if (this->context_->unbind (n[0].id,
n[0].kind) == -1)
@@ -504,8 +506,7 @@ TAO_Hash_Naming_Context::bind_new_context (const CosNaming::Name& n)
// target context.
if (name_len > 1)
{
- CosNaming::NamingContext_var context =
- get_context (n);
+ CosNaming::NamingContext_var context = this->get_context (n);
CosNaming::Name simple_name;
simple_name.length (1);
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h b/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h
index c9090d987f8..677e9c6956d 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/Hash_Naming_Context.h
@@ -216,6 +216,8 @@ public:
/// Returns the Default POA of this Servant object
virtual PortableServer::POA_ptr _default_POA (void);
+ TAO_SYNCH_RW_MUTEX &lock (void);
+
protected:
// = Helper method used by other methods.
@@ -244,7 +246,7 @@ protected:
TAO_Naming_Context *interface_;
/// Lock used to serialize access to the underlying data structure.
- TAO_SYNCH_RECURSIVE_MUTEX lock_;
+ TAO_SYNCH_RW_MUTEX lock_;
/**
* Flag indicating whether this Naming Context is no longer valid.
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp
index 6a90a325ae9..a1b4e08ef72 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/Persistent_Naming_Context.cpp
@@ -353,11 +353,6 @@ TAO_Persistent_Naming_Context::make_new_context (PortableServer::POA_ptr poa,
CosNaming::NamingContext_ptr
TAO_Persistent_Naming_Context::new_context (void)
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
// Check to make sure this object didn't have <destroy> method
// invoked on it.
if (this->destroyed_)
@@ -371,10 +366,10 @@ TAO_Persistent_Naming_Context::new_context (void)
(*this->counter_)++);
CosNaming::NamingContext_var result =
- make_new_context (this->poa_.in (),
- poa_id,
- this->persistent_context_->total_size (),
- this->index_);
+ this->make_new_context (this->poa_.in (),
+ poa_id,
+ this->persistent_context_->total_size (),
+ this->index_);
return result._retn ();
}
@@ -391,12 +386,6 @@ TAO_Persistent_Naming_Context::list (CORBA::ULong how_many,
CosNaming::BindingList (0),
CORBA::NO_MEMORY ());
- // Obtain a lock before we proceed with the operation.
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
// Check to make sure this object didn't have <destroy> method
// invoked on it.
if (this->destroyed_)
@@ -437,16 +426,22 @@ TAO_Persistent_Naming_Context::list (CORBA::ULong how_many,
bl->length (n);
ENTRY_DEF *hash_entry = 0;
-
- for (CORBA::ULong i = 0; i < n; i++)
- {
- hash_iter->next (hash_entry);
- hash_iter->advance ();
-
- if (ITER_SERVANT::populate_binding (hash_entry, bl[i]) == 0)
+ {
+ // Obtain a lock before we proceed with the operation.
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX,
+ ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
+
+ for (CORBA::ULong i = 0; i < n; i++)
+ {
+ hash_iter->next (hash_entry);
+ hash_iter->advance ();
+
+ if (ITER_SERVANT::populate_binding (hash_entry, bl[i]) == 0)
throw CORBA::NO_MEMORY();
- }
-
+ }
+ }
// Now we are done with the BindingsList, and we can follow up on
// the iterator business.
@@ -457,7 +452,7 @@ TAO_Persistent_Naming_Context::list (CORBA::ULong how_many,
{
// Create a BindingIterator for return.
ACE_NEW_THROW_EX (bind_iter,
- ITER_SERVANT (this, hash_iter, this->poa_.in (), this->lock_),
+ ITER_SERVANT (this, hash_iter, this->poa_.in ()),
CORBA::NO_MEMORY ());
// Release <hash_iter> from auto pointer, and start using the
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp
index 1ce1053324b..48c400de01b 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.cpp
@@ -260,15 +260,28 @@ TAO_Storable_Naming_Context::load_map (TAO::Storable_Base& storable)
}
TAO_Storable_Naming_Context::
-File_Open_Lock_and_Check::File_Open_Lock_and_Check (
- TAO_Storable_Naming_Context * context,
- Method_Type method_type)
+File_Open_Lock_and_Check::File_Open_Lock_and_Check
+(TAO_Storable_Naming_Context * context,
+ Method_Type method_type,
+ bool force_load)
: TAO::Storable_File_Guard (TAO_Storable_Naming_Context::redundant_),
context_(context)
{
try
{
- this->init (method_type);
+ this->init_no_load (method_type);
+ if (force_load)
+ this->reload ();
+ else
+ {
+ if (this->object_obsolete ())
+ {
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX, ace_mon,
+ context->lock (),
+ CORBA::INTERNAL ());
+ this->reload ();
+ }
+ }
}
catch (const TAO::Storable_Exception &)
{
@@ -375,8 +388,7 @@ TAO_Storable_Naming_Context::TAO_Storable_Naming_Context (
TAO_Storable_Naming_Context_Factory *cxt_factory,
TAO::Storable_Factory *factory,
size_t hash_table_size)
- : TAO_Hash_Naming_Context (poa,
- context_name),
+ : TAO_Hash_Naming_Context (poa, context_name),
counter_ (0),
storable_context_ (0),
orb_(CORBA::ORB::_duplicate (orb)),
@@ -418,6 +430,45 @@ TAO_Storable_Naming_Context::~TAO_Storable_Naming_Context (void)
}
}
+void
+TAO_Storable_Naming_Context::context_written (void)
+{
+ // No-op. Overridden by derived class.
+}
+
+bool
+TAO_Storable_Naming_Context::is_obsolete (time_t stored_time)
+{
+ return (this->context_ == 0) ||
+ (stored_time > this->last_changed_);
+}
+
+void
+TAO_Storable_Naming_Context::verify_not_destroyed (void)
+{
+ File_Open_Lock_and_Check flck (this, SFG::ACCESSOR, false);
+ if (this->destroyed_)
+ throw CORBA::OBJECT_NOT_EXIST ();
+}
+
+bool
+TAO_Storable_Naming_Context::nested_context (const CosNaming::Name &n,
+ CosNaming::NamingContext_out nc)
+{
+ CORBA::ULong name_len = n.length ();
+
+ if (name_len == 0)
+ throw CosNaming::NamingContext::InvalidName();
+
+ if (name_len > 1)
+ {
+ nc = this->get_context (n);
+ return true;
+ }
+ nc = CosNaming::NamingContext::_nil ();
+ return false;
+}
+
CosNaming::NamingContext_ptr
TAO_Storable_Naming_Context::make_new_context (
CORBA::ORB_ptr orb,
@@ -428,7 +479,7 @@ TAO_Storable_Naming_Context::make_new_context (
TAO_Storable_Naming_Context **new_context)
{
ACE_TRACE("make_new_context");
- // Store the stub we will return here.
+
CosNaming::NamingContext_var result;
// Put together a servant for the new Naming Context.
@@ -490,20 +541,6 @@ CosNaming::NamingContext_ptr
TAO_Storable_Naming_Context::new_context (void)
{
ACE_TRACE("new_context");
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- {
- // Open the backing file
- File_Open_Lock_and_Check flck(this, SFG::ACCESSOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
- }
TAO_NS_Persistence_Global global;
TAO_Storable_Naming_Context_ReaderWriter rw(*gfl_.get());
@@ -567,64 +604,38 @@ void
TAO_Storable_Naming_Context::rebind (const CosNaming::Name& n,
CORBA::Object_ptr obj)
{
- ACE_TRACE("rebind");
- // Get the length of the name.
- CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
- if (name_len == 0)
- throw CosNaming::NamingContext::InvalidName();
-
- // we didn't need a lock to check the input arg, but now we do
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
- File_Open_Lock_and_Check flck(this, name_len > 1 ? SFG::ACCESSOR : SFG::MUTATOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
- // If we received compound name, resolve it to get the context in
- // which the rebinding should take place, then perform the rebinding
- // on target context.
- if (name_len > 1)
+ ACE_TRACE("TAO_Storable_Naming_Context::rebind");
+ CosNaming::NamingContext_var context;
+ if (this->nested_context (n, context.out ()))
{
- // This had been a read on the file so now we are done with it
- flck.release();
-
- ace_mon.release ();
-
- CosNaming::NamingContext_var context =
- get_context (n);
-
CosNaming::Name simple_name;
simple_name.length (1);
- simple_name[0] = n[name_len - 1];
+ simple_name[0] = n[n.length () - 1];
context->rebind (simple_name, obj);
}
- // If we received a simple name, we need to rebind it in this
- // context.
else
{
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
+ File_Open_Lock_and_Check flck (this, SFG::MUTATOR);
+ if (this->destroyed_)
+ throw CORBA::OBJECT_NOT_EXIST ();
+
int result = this->context_->rebind (n[0].id,
n[0].kind,
obj,
CosNaming::nobject);
- // Check for error conditions.
if (result == -1)
throw CORBA::INTERNAL ();
else if (result == -2)
- throw CosNaming::NamingContext::NotFound(
+ throw CosNaming::NamingContext::NotFound (
CosNaming::NamingContext::not_object,
n);
- this->Write(flck.peer());
+ this->Write (flck.peer());
}
}
@@ -633,52 +644,27 @@ TAO_Storable_Naming_Context::bind_context (const CosNaming::Name &n,
CosNaming::NamingContext_ptr nc)
{
ACE_TRACE("TAO_Storable_Naming_Context::bind_context");
- // Get the length of the name.
- CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
- if (name_len == 0)
- throw CosNaming::NamingContext::InvalidName();
- // Do not allow binding of nil context reference.
if (CORBA::is_nil (nc))
throw CORBA::BAD_PARAM ();
- // we didn't need a lock to check the input arg, but now we do
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
- File_Open_Lock_and_Check flck (this, name_len > 1 ? SFG::ACCESSOR : SFG::MUTATOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
- // If we received compound name, resolve it to get the context in
- // which the binding should take place, then perform the binding
- // on target context.
- if (name_len > 1)
+ CosNaming::NamingContext_var context;
+ if (this->nested_context (n, context.out ()))
{
- // This had been a read on the file so now we are done with it
- flck.release ();
-
- ace_mon.release ();
-
- CosNaming::NamingContext_var context =
- get_context (n);
-
CosNaming::Name simple_name;
simple_name.length (1);
- simple_name[0] = n[name_len - 1];
+ simple_name[0] = n[n.length () - 1];
context->bind_context (simple_name, nc);
}
- // If we received a simple name, we need to bind it in this context.
else
{
- // Try binding the name.
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
+ File_Open_Lock_and_Check flck (this, SFG::MUTATOR);
+ if (this->destroyed_)
+ throw CORBA::OBJECT_NOT_EXIST ();
+
int result = this->context_->bind (n[0].id,
n[0].kind,
nc,
@@ -696,56 +682,34 @@ TAO_Storable_Naming_Context::bind_context (const CosNaming::Name &n,
void
TAO_Storable_Naming_Context::rebind_context (const CosNaming::Name &n,
- CosNaming::NamingContext_ptr nc)
+ CosNaming::NamingContext_ptr nc)
{
- ACE_TRACE("rebind_context");
- // Get the length of the name.
- CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
- if (name_len == 0)
- throw CosNaming::NamingContext::InvalidName();
-
- // we didn't need a lock to check the input arg, but now we do
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
- File_Open_Lock_and_Check flck (this, name_len > 1 ? SFG::ACCESSOR : SFG::MUTATOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
+ ACE_TRACE("TAO_Storable_Naming_Context::rebind_context");
+ if (CORBA::is_nil (nc))
+ throw CORBA::BAD_PARAM ();
- // If we received compound name, resolve it to get the context in
- // which the rebinding should take place, then perform the rebinding
- // on target context.
- if (name_len > 1)
+ CosNaming::NamingContext_var context;
+ if (this->nested_context (n, context.out ()))
{
- // This had been a read on the file so now we are done with it
- flck.release ();
-
- ace_mon.release ();
-
- CosNaming::NamingContext_var context =
- get_context (n);
-
CosNaming::Name simple_name;
simple_name.length (1);
- simple_name[0] = n[name_len - 1];
+ simple_name[0] = n[n.length () - 1];
context->rebind_context (simple_name, nc);
}
- // If we received a simple name, we need to rebind it in this
- // context.
else
{
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
+
+ File_Open_Lock_and_Check flck (this, SFG::MUTATOR);
+ if (this->destroyed_)
+ throw CORBA::OBJECT_NOT_EXIST ();
+
int result = this->context_->rebind (n[0].id,
n[0].kind,
nc,
CosNaming::ncontext);
- // Check for error conditions.
if (result == -1)
throw CORBA::INTERNAL ();
else if (result == -2)
@@ -757,141 +721,62 @@ TAO_Storable_Naming_Context::rebind_context (const CosNaming::Name &n,
}
}
-CORBA::Object_ptr
-TAO_Storable_Naming_Context::resolve (const CosNaming::Name& n)
+CosNaming::NamingContext_ptr
+TAO_Storable_Naming_Context::bind_new_context (const CosNaming::Name& n)
{
- ACE_TRACE("resolve");
- // Get the length of the name.
- CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
- if (name_len == 0)
- throw CosNaming::NamingContext::InvalidName();
-
- // Stores the binding type for the first name component.
- CosNaming::BindingType type;
- // Stores the object reference bound to the first name component.
- CORBA::Object_var result;
-
- {
- // we didn't need a lock to check the input arg, but now we do
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon, this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
- File_Open_Lock_and_Check flck (this, SFG::ACCESSOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
+ ACE_TRACE("TAO_Storable_Naming_Context::bind_new_context");
+ CosNaming::NamingContext_var context;
+ if (this->nested_context (n, context.out ()))
+ {
+ CosNaming::Name simple_name;
+ simple_name.length (1);
+ simple_name[0] = n[n.length () - 1];
+ return context->bind_new_context (simple_name);
+ }
- // Resolve the first component of the name.
- flck.release();
+ CosNaming::NamingContext_var result = new_context ();
- if (this->context_->find (n[0].id,
- n[0].kind,
- result.out (),
- type) == -1)
- {
- throw CosNaming::NamingContext::NotFound
- (CosNaming::NamingContext::missing_node, n);
- }
- }
-
- // If the name we have to resolve is a compound name, we need to
- // resolve it recursively.
- if (name_len > 1)
+ try
{
- CosNaming::NamingContext_var context =
- CosNaming::NamingContext::_nil ();
-
- if (type == CosNaming::ncontext)
+ bind_context (n, result.in ());
+ }
+ catch (const CORBA::Exception&)
+ {
+ try
{
- // Narrow to NamingContext.
- context = CosNaming::NamingContext::_narrow (result.in ());
+ result->destroy ();
}
- else
- // The first name component wasn't bound to a NamingContext.
- throw CosNaming::NamingContext::NotFound(
- CosNaming::NamingContext::not_context,
- n);
-
- // If narrow failed...
- if (CORBA::is_nil (context.in ()))
- throw CosNaming::NamingContext::NotFound(
- CosNaming::NamingContext::not_context,
- n);
- else
+ catch (const CORBA::Exception&)
{
- // Successfully resolved the first name component, need to
- // recursively call resolve on <n> without the first component.
-
- // We need a name just like <n> but without the first
- // component. Instead of copying data we can reuse <n>'s
- // buffer since we will only be using it for 'in' parameters
- // (no modifications).
- CosNaming::Name rest_of_name
- (n.maximum () - 1,
- n.length () - 1,
- const_cast<CosNaming::NameComponent*> (n.get_buffer ()) + 1);
-
- // If there are any exceptions, they will propagate up.
- return context->resolve (rest_of_name);
+ // Do nothing?
}
+ throw;
}
- // If the name we had to resolve was simple, we just need to return
- // the result.
return result._retn ();
}
void
TAO_Storable_Naming_Context::unbind (const CosNaming::Name& n)
{
- ACE_TRACE("unbind");
- // Get the length of the name.
- CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
- if (name_len == 0)
- throw CosNaming::NamingContext::InvalidName();
-
- // we didn't need a lock to check the input arg, but now we do
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
- File_Open_Lock_and_Check flck (this, name_len > 1 ?
- SFG::ACCESSOR : SFG::MUTATOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
- // If we received compound name, resolve it to get the context in
- // which the unbinding should take place, then perform the unbinding
- // on target context.
- if (name_len > 1)
+ ACE_TRACE("TAO_Storable_Naming_Context::unbind");
+ CosNaming::NamingContext_var context;
+ if (this->nested_context (n, context.out ()))
{
- // This had been a read on the file so now we are done with it
- flck.release ();
-
- ace_mon.release ();
-
- CosNaming::NamingContext_var context =
- get_context (n);
-
CosNaming::Name simple_name;
simple_name.length (1);
- simple_name[0] = n[name_len - 1];
+ simple_name[0] = n[n.length () - 1];
context->unbind (simple_name);
}
- // If we received a simple name, we need to unbind it in this
- // context.
else
{
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
+
+ File_Open_Lock_and_Check flck (this, SFG::MUTATOR);
+ if (this->destroyed_)
+ throw CORBA::OBJECT_NOT_EXIST ();
+
if (this->context_->unbind (n[0].id,
n[0].kind) == -1)
throw CosNaming::NamingContext::NotFound(
@@ -902,249 +787,152 @@ TAO_Storable_Naming_Context::unbind (const CosNaming::Name& n)
}
}
-CosNaming::NamingContext_ptr
-TAO_Storable_Naming_Context::bind_new_context (const CosNaming::Name& n)
+void
+TAO_Storable_Naming_Context::bind (const CosNaming::Name& n,
+ CORBA::Object_ptr obj)
{
- ACE_TRACE("bind_new_context");
- // Get the length of the name.
- CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
- if (name_len == 0)
- throw CosNaming::NamingContext::InvalidName();
-
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
- // Open the backing file
- File_Open_Lock_and_Check flck (this, name_len > 1 ?
- SFG::ACCESSOR : SFG::MUTATOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
- // If we received compound name, resolve it to get the context in
- // which the binding should take place, then perform the operation on
- // target context.
- if (name_len > 1)
+ ACE_TRACE("TAO_Storable_Naming_Context::bind");
+ CosNaming::NamingContext_var context;
+ if (this->nested_context (n, context.out ()))
{
- // This had been a read on the file so now we are done with it
- flck.release ();
-
- ace_mon.release ();
-
- CosNaming::NamingContext_var context =
- get_context (n);
-
CosNaming::Name simple_name;
simple_name.length (1);
- simple_name[0] = n[name_len - 1];
- return context->bind_new_context (simple_name);
+ simple_name[0] = n[n.length() - 1];
+ context->bind (simple_name, obj);
}
- // If we received a simple name, we need to bind it in this context.
-
- // This had been a read on the file so now we are done with it
- flck.release();
-
- // Stores our new Naming Context.
- CosNaming::NamingContext_var result =
- CosNaming::NamingContext::_nil ();
+ else
+ {
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX, ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
+ File_Open_Lock_and_Check flck(this, SFG::MUTATOR);
+ if (this->destroyed_)
+ throw CORBA::OBJECT_NOT_EXIST ();
- // Create new context.
- result = new_context ();
+ int result = this->context_->bind (n[0].id,
+ n[0].kind,
+ obj,
+ CosNaming::nobject);
+ if (result == 1)
+ throw CosNaming::NamingContext::AlreadyBound();
+ else if (result == -1)
+ throw CORBA::INTERNAL ();
- // Bind the new context to the name.
- try
- {
- bind_context (n,
- result.in ());
- }
- catch (const CORBA::Exception&)
- {
- {
- try
- {
- result->destroy ();
- }
- catch (const CORBA::Exception&)
- {
- // Do nothing?
- }
- }
- // Re-raise the exception in bind_context()
- throw;
+ this->Write (flck.peer());
}
- return result._retn ();
}
void
TAO_Storable_Naming_Context::destroy (void)
{
- ACE_TRACE("destroy");
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
+ ACE_TRACE("TAO_Storable_Naming_Context::destroy");
+ ACE_WRITE_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
+ ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
File_Open_Lock_and_Check flck(this, SFG::MUTATOR);
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
if (this->destroyed_)
throw CORBA::OBJECT_NOT_EXIST ();
if (this->context_->current_size () != 0)
- throw CosNaming::NamingContext::NotEmpty();
+ throw CosNaming::NamingContext::NotEmpty ();
- // Destroy is a no-op on a root context.
if (!root ())
{
this->destroyed_ = 2;
- // Remove self from POA. Because of reference counting, the POA
- // will automatically delete the servant when all pending requests
- // on this servant are complete.
-
- PortableServer::POA_var poa =
- this->_default_POA ();
+ PortableServer::POA_var poa = this->_default_POA ();
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId (poa_id_.fast_rep ());
-
poa->deactivate_object (id.in ());
this->Write(flck.peer());
}
}
-void
-TAO_Storable_Naming_Context::context_written (void)
-{
- // No-op. Overridden by derived class.
-}
-
-bool
-TAO_Storable_Naming_Context::is_obsolete (time_t stored_time)
+CORBA::Object_ptr
+TAO_Storable_Naming_Context::resolve (const CosNaming::Name& n)
{
- // If the context_ has not been populated or
- // the time in the persistent store is greater than this
- // object last change time, the context is obsolete
- return (this->context_ == 0) ||
- (stored_time > this->last_changed_);
-}
+ ACE_TRACE("TAO_Storable_Naming_Context::resolve");
-void
-TAO_Storable_Naming_Context::bind (const CosNaming::Name& n,
- CORBA::Object_ptr obj)
-{
- ACE_TRACE("TAO_Storable_Naming_Context::bind");
- // Get the length of the name.
CORBA::ULong name_len = n.length ();
-
- // Check for invalid name.
if (name_len == 0)
throw CosNaming::NamingContext::InvalidName();
- // we didn't need a lock to check the input arg, but now we do
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX, ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Open the backing file
- File_Open_Lock_and_Check flck(this, name_len > 1 ?
- SFG::ACCESSOR : SFG::MUTATOR);
+ CosNaming::BindingType type;
+ CORBA::Object_var result;
+ {
+ this->verify_not_destroyed ();
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX, ace_mon, this->lock_,
+ CORBA::INTERNAL ());
+ if (this->context_->find (n[0].id,
+ n[0].kind,
+ result.out (),
+ type) == -1)
+ {
+ throw CosNaming::NamingContext::NotFound
+ (CosNaming::NamingContext::missing_node, n);
+ }
+ }
- // If we received compound name, resolve it to get the context in
- // which the binding should take place, then perform the binding
- // on target context.
if (name_len > 1)
{
- // This had been a read on the file so now we are done with it
- flck.release();
- // Need to release the lock before nested invocation
- ace_mon.release();
-
- CosNaming::NamingContext_var context = get_context (n);
+ CosNaming::NamingContext_var context =
+ CosNaming::NamingContext::_nil ();
- CosNaming::Name simple_name;
- simple_name.length (1);
- simple_name[0] = n[name_len - 1];
- context->bind (simple_name, obj);
- }
- // If we received a simple name, we need to bind it in this context.
- else
- {
- // Try binding the name.
- int result = this->context_->bind (n[0].id,
- n[0].kind,
- obj,
- CosNaming::nobject);
- if (result == 1)
- throw CosNaming::NamingContext::AlreadyBound();
+ if (type == CosNaming::ncontext)
+ {
+ context = CosNaming::NamingContext::_narrow (result.in ());
+ }
+ else
+ throw CosNaming::NamingContext::NotFound(
+ CosNaming::NamingContext::not_context,
+ n);
- // Something went wrong with the internal structure
- else if (result == -1)
- throw CORBA::INTERNAL ();
+ if (CORBA::is_nil (context.in ()))
+ throw CosNaming::NamingContext::NotFound(
+ CosNaming::NamingContext::not_context,
+ n);
+ else
+ {
+ CosNaming::Name rest_of_name
+ (n.maximum () - 1,
+ n.length () - 1,
+ const_cast<CosNaming::NameComponent*> (n.get_buffer ()) + 1);
- this->Write (flck.peer());
+ return context->resolve (rest_of_name);
+ }
}
+ return result._retn ();
}
-
void
TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
CosNaming::BindingList_out &bl,
CosNaming::BindingIterator_out &bi)
{
- ACE_TRACE("list");
- // Allocate nil out parameters in case we won't be able to complete
- // the operation.
+ ACE_TRACE("TAO_Storable_Naming_Context::list");
bi = CosNaming::BindingIterator::_nil ();
+
ACE_NEW_THROW_EX (bl,
CosNaming::BindingList (0),
CORBA::NO_MEMORY ());
- // Obtain a lock before we proceed with the operation.
- ACE_GUARD_THROW_EX (ACE_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ this->verify_not_destroyed ();
- // Open the backing file
- File_Open_Lock_and_Check flck(this, SFG::ACCESSOR);
+ ACE_READ_GUARD_THROW_EX (ACE_SYNCH_RW_MUTEX,
+ ace_mon,
+ this->lock_,
+ CORBA::INTERNAL ());
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
- // We have the map in memory, let the disk go
- flck.release();
-
- // Dynamically allocate iterator for traversing the underlying hash map.
HASH_MAP::ITERATOR *hash_iter = 0;
ACE_NEW_THROW_EX (hash_iter,
HASH_MAP::ITERATOR (storable_context_->map ()),
CORBA::NO_MEMORY ());
- // Store <hash_iter temporarily in auto pointer, in case we'll have
- // some failures and throw an exception.
ACE_Auto_Basic_Ptr<HASH_MAP::ITERATOR> temp (hash_iter);
// Silliness below is required because of broken old g++!!! E.g.,
@@ -1155,27 +943,14 @@ TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
typedef ACE_Hash_Map_Manager<TAO_Storable_ExtId,
TAO_Storable_IntId,
ACE_Null_Mutex>::ENTRY ENTRY_DEF;
-
- // Typedef to the type of BindingIterator servant for ease of use.
typedef TAO_Bindings_Iterator<ITER_DEF, ENTRY_DEF> ITER_SERVANT;
- // A pointer to BindingIterator servant.
- ITER_SERVANT *bind_iter = 0;
-
- // Number of bindings that will go into the BindingList <bl>.
- CORBA::ULong n;
-
- // Calculate number of bindings that will go into <bl>.
- if (this->context_->current_size () > how_many)
- n = how_many;
- else
- n = static_cast<CORBA::ULong> (this->context_->current_size ());
-
- // Use the hash map iterator to populate <bl> with bindings.
+ CORBA::ULong n = (this->context_->current_size () > how_many) ?
+ how_many :
+ static_cast<CORBA::ULong> (this->context_->current_size ());
bl->length (n);
ENTRY_DEF *hash_entry = 0;
-
for (CORBA::ULong i = 0; i < n; i++)
{
hash_iter->next (hash_entry);
@@ -1185,37 +960,26 @@ TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
throw CORBA::NO_MEMORY();
}
- // Now we are done with the BindingsList, and we can follow up on
- // the BindingIterator business.
-
- // If we do not need to pass back BindingIterator.
if (this->context_->current_size () <= how_many)
return;
else if (redundant_)
{
- // *** This is a problem. Is there an exception we can throw? ***
- ACE_UNUSED_ARG (bind_iter);
throw CORBA::NO_IMPLEMENT ();
}
else
{
- // Create a BindingIterator for return.
+ ITER_SERVANT *bind_iter = 0;
ACE_NEW_THROW_EX (bind_iter,
- ITER_SERVANT (this, hash_iter,
- this->poa_.in (), this->lock_),
+ ITER_SERVANT (this, hash_iter, this->poa_.in ()),
CORBA::NO_MEMORY ());
- // Release <hash_iter> from auto pointer, and start using
- // reference counting to control our servant.
temp.release ();
- PortableServer::ServantBase_var iter = bind_iter;
+ PortableServer::ServantBase_var svt = bind_iter;
// Increment reference count on this Naming Context, so it doesn't get
// deleted before the BindingIterator servant gets deleted.
interface_->_add_ref ();
- // Register with the POA.
- // Is an ACE_UINT32 enough?
char poa_id[BUFSIZ];
ACE_OS::snprintf (poa_id,
BUFSIZ,
@@ -1225,9 +989,9 @@ TAO_Storable_Naming_Context::list (CORBA::ULong how_many,
PortableServer::ObjectId_var id =
PortableServer::string_to_ObjectId (poa_id);
- this->poa_->activate_object_with_id (id.in (),
- bind_iter);
- bi = bind_iter->_this ();
+ this->poa_->activate_object_with_id (id.in (), svt.in());
+ CORBA::Object_var obj = this->poa_->id_to_reference (id.in ());
+ bi = CosNaming::BindingIterator::_narrow (obj.in());
}
}
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h
index 85a60cb9beb..7e5a290ecd6 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h
+++ b/TAO/orbsvcs/orbsvcs/Naming/Storable_Naming_Context.h
@@ -362,6 +362,19 @@ public:
protected:
/**
+ * A helper function to ensure the current object was not destroyed by raising
+ * an exception if it was. Uses the lock as a Reader.
+ */
+ void verify_not_destroyed (void);
+
+ /**
+ * A helper function to validate the name argument and return a final context
+ * if the supplied name is nested
+ */
+ bool nested_context (const CosNaming::Name &n,
+ CosNaming::NamingContext_out nc);
+
+ /**
* An internal callback invoked by the File_Open_Lock_and_Check object to
* signal that this context was updated and written to disk.
* This will have been done after the file is closed. Check the
@@ -433,9 +446,10 @@ public TAO::Storable_File_Guard
{
public:
- /// Constructor - we always need the object which we guard.
+ /// Constructor
File_Open_Lock_and_Check (TAO_Storable_Naming_Context * context,
- Method_Type method_type);
+ Method_Type method_type,
+ bool loadnow = true);
~File_Open_Lock_and_Check ();
diff --git a/TAO/orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp b/TAO/orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp
index 34eef002ead..527e568f82e 100644
--- a/TAO/orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp
+++ b/TAO/orbsvcs/orbsvcs/Naming/Transient_Naming_Context.cpp
@@ -185,16 +185,6 @@ TAO_Transient_Naming_Context::make_new_context (PortableServer::POA_ptr poa,
CosNaming::NamingContext_ptr
TAO_Transient_Naming_Context::new_context (void)
{
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
-
- // Check to make sure this object didn't have <destroy> method
- // invoked on it.
- if (this->destroyed_)
- throw CORBA::OBJECT_NOT_EXIST ();
-
// Generate a POA id for the new context.
char poa_id[BUFSIZ];
ACE_OS::sprintf (poa_id,
@@ -224,10 +214,9 @@ TAO_Transient_Naming_Context::list (CORBA::ULong how_many,
CORBA::NO_MEMORY ());
// Obtain a lock before we proceed with the operation.
- ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
- ace_mon,
- this->lock_,
- CORBA::INTERNAL ());
+ ACE_READ_GUARD_THROW_EX (TAO_SYNCH_RW_MUTEX,
+ ace_mon, this->lock_,
+ CORBA::INTERNAL ());
// Check to make sure this object didn't have <destroy> method
// invoked on it.
@@ -289,7 +278,7 @@ TAO_Transient_Naming_Context::list (CORBA::ULong how_many,
{
// Create a BindingIterator for return.
ACE_NEW_THROW_EX (bind_iter,
- ITER_SERVANT (this, hash_iter, this->poa_.in (), this->lock_),
+ ITER_SERVANT (this, hash_iter, this->poa_.in ()),
CORBA::NO_MEMORY ());
// Release <hash_iter> from auto pointer, and start using
diff --git a/TAO/tao/Storable_File_Guard.cpp b/TAO/tao/Storable_File_Guard.cpp
index d32c4c5380f..adb990ca672 100644
--- a/TAO/tao/Storable_File_Guard.cpp
+++ b/TAO/tao/Storable_File_Guard.cpp
@@ -28,10 +28,11 @@ Storable_File_Guard (bool redundant, bool use_backup)
TAO::Storable_File_Guard::
~Storable_File_Guard ()
{
+ delete fl_;
}
void
-TAO::Storable_File_Guard::init(Method_Type method_type)
+TAO::Storable_File_Guard::init_no_load(Method_Type method_type)
{
ACE_CString mode;
@@ -105,11 +106,15 @@ TAO::Storable_File_Guard::init(Method_Type method_type)
// Create the stream
fl_ = this->create_stream(mode.c_str ());
+}
+
+void
+TAO::Storable_File_Guard::reload (void)
+{
if (redundant_)
{
- if (fl_->open() != 0)
+ if (fl_->open () != 0)
{
- delete fl_;
if (TAO_debug_level > 0)
{
TAOLIB_DEBUG ((LM_DEBUG,
@@ -120,10 +125,9 @@ TAO::Storable_File_Guard::init(Method_Type method_type)
}
// acquire a lock on it
- if (fl_ -> flock(0, 0, 0) != 0)
+ if (fl_->flock (0, 0, 0) != 0)
{
- fl_->close();
- delete fl_;
+ fl_->close ();
if (TAO_debug_level > 0)
{
TAOLIB_DEBUG ((LM_DEBUG,
@@ -149,18 +153,17 @@ TAO::Storable_File_Guard::init(Method_Type method_type)
}
else if ( ! this->is_loaded_from_stream () || (rwflags_ & mode_write) )
{
- bool file_has_data = fl_->exists();
+ bool file_has_data = fl_->exists ();
- if (fl_->open() != 0)
+ if (fl_->open () != 0)
{
- delete fl_;
if (TAO_debug_level > 0)
{
TAOLIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Storable_File_Guard:Open ")
ACE_TEXT ("failed in non-redundant\n")));
}
- throw CORBA::PERSIST_STORE();
+ throw CORBA::PERSIST_STORE ();
}
// now that the file is successfully opened
@@ -172,11 +175,13 @@ TAO::Storable_File_Guard::init(Method_Type method_type)
this->load ();
}
}
- else
- {
- // Need to insure that fl_ gets deleted
- delete fl_;
- }
+}
+
+void
+TAO::Storable_File_Guard::init(Method_Type method_type)
+{
+ this->init_no_load (method_type);
+ this->reload ();
}
bool
@@ -218,10 +223,9 @@ TAO::Storable_File_Guard::release (void)
}
// Release the lock
- fl_->funlock(0, 0, 0);
+ fl_->funlock (0, 0, 0);
}
- fl_->close();
- delete fl_;
+ fl_->close ();
closed_ = 1;
}
diff --git a/TAO/tao/Storable_File_Guard.h b/TAO/tao/Storable_File_Guard.h
index 467ef607474..0d90dca16ae 100644
--- a/TAO/tao/Storable_File_Guard.h
+++ b/TAO/tao/Storable_File_Guard.h
@@ -77,6 +77,16 @@ namespace TAO
/// of this class.
void init (Method_Type method_type);
+ /// Initializes the backing store file object but does not
+ /// actually load the data. This can be called without locks,
+ /// allowing the caller to decide whether or not to then lock
+ /// and complete the load.
+ void init_no_load (Method_Type method_type);
+
+ /// Complete the initialization of the containing object, should
+ /// be called with lock held after calling init_no_load
+ void reload (void);
+
/// Check if the object is current with the last update.
virtual bool object_obsolete (void);