summaryrefslogtreecommitdiff
path: root/TAO/tao
diff options
context:
space:
mode:
authorbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-02-27 17:44:03 +0000
committerbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-02-27 17:44:03 +0000
commit6bfae336ac7b66ac7b1fab9318b6610a5cf0abe2 (patch)
tree9676d0fab0bf9ed0f2ed5a71ad5542bc97e07412 /TAO/tao
parent432f0c98238b924ae47ad17c18a0265e458ffc83 (diff)
downloadATCD-6bfae336ac7b66ac7b1fab9318b6610a5cf0abe2.tar.gz
ChangeLogTag: Tue Feb 27 11:34:00 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO/tao')
-rw-r--r--TAO/tao/Invocation.cpp77
-rw-r--r--TAO/tao/Invocation.h15
-rw-r--r--TAO/tao/Stub.cpp109
-rw-r--r--TAO/tao/Stub.h31
-rw-r--r--TAO/tao/Stub.i6
5 files changed, 165 insertions, 73 deletions
diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp
index 20d23592dd9..a81c6cbcf13 100644
--- a/TAO/tao/Invocation.cpp
+++ b/TAO/tao/Invocation.cpp
@@ -94,7 +94,6 @@ TAO_GIOP_Invocation::TAO_GIOP_Invocation (void)
profile_ (0),
endpoint_ (0),
max_wait_time_ (0),
- ior_info_ (),
rt_context_initialized_ (0),
restart_flag_ (0),
forward_reference_ (),
@@ -128,7 +127,6 @@ TAO_GIOP_Invocation::TAO_GIOP_Invocation (TAO_Stub *stub,
profile_ (0),
endpoint_ (0),
max_wait_time_ (0),
- ior_info_ (),
rt_context_initialized_ (0),
restart_flag_ (0),
forward_reference_ (),
@@ -350,8 +348,26 @@ TAO_GIOP_Invocation::prepare_header (CORBA::Octet response_flags,
// We need to call the method seperately. If there is no
// IOP::IOR info, the call would create the info and return the
// index that we need.
- CORBA::ULong index = this->create_ior_info ();
- this->target_spec_.target_specifier (this->ior_info_,
+ CORBA::ULong index = 0;
+
+ IOP::IOR *ior_info = 0;
+ int retval = this->stub_->create_ior_info (ior_info,
+ index,
+ ACE_TRY_ENV);
+ ACE_CHECK;
+
+ if (retval == -1)
+ {
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("TAO (%P|%t) Error in finding index for \n")
+ ACE_TEXT ("IOP::IOR \n")));
+ }
+ return;
+ }
+
+ this->target_spec_.target_specifier (*ior_info,
index);
}
@@ -515,60 +531,7 @@ TAO_GIOP_Invocation::location_forward (CORBA::Object_ptr forward,
return TAO_INVOKE_RESTART;
}
-CORBA::ULong
-TAO_GIOP_Invocation::create_ior_info (void)
-{
- if (this->ior_info_.profiles.length () == 0)
- {
- // We are making a copy, it is expensive. We want a copy of the
- // profiles as we dont want to modify the profile set held by
- // the Stub classes. We may want to hold a lock for doing
- // that. To avoid unnecssary complications we make a copy and
- // get the info
-
- // @@ There should be a better way to do this - Bala
- // @@ Bala, your code is not exception-safe. The call below
- // allocates memory, and could very well return 0. In such
- // case, the second call below would seg fault.
- TAO_MProfile *multi_prof =
- this->stub_->make_profiles ();
-
- // Get the number of elements
- CORBA::ULong count = multi_prof->profile_count ();
-
- // Set the number of elements in the sequence of tagged_profile
- this->ior_info_.profiles.length (count);
-
- // Call the create_tagged_profile one every member of the
- // profile and make the sequence
- for (CORBA::ULong index = 0; index < count; ++index)
- {
- TAO_Profile *prof = multi_prof->get_profile (index);
-
- this->ior_info_.profiles[index] = prof->create_tagged_profile ();
- }
-
- delete multi_prof;
- }
-
- // Figure out the index of the profile we are using for invocation.
-
- // @@ Bala, you are using base_profiles, which means this will not
- // work if there was forwarding ... But it seems the problem isn't
- // just here, but the whole addressing mode thing won't work if
- // there was forwarding.
- const TAO_MProfile &mprofile = this->stub_->base_profiles ();
-
- for (CORBA::ULong i = 0; i < mprofile.profile_count (); ++i)
- {
- if (mprofile.get_profile (i) == this->profile_)
- return i;
-
- }
- // If there was forwarding the loop above won't find a match.
- return mprofile.get_current_handle ();
-}
void
TAO_GIOP_Invocation::add_rt_service_context (CORBA_Environment &ACE_TRY_ENV)
diff --git a/TAO/tao/Invocation.h b/TAO/tao/Invocation.h
index 75def9aa75e..3296c919009 100644
--- a/TAO/tao/Invocation.h
+++ b/TAO/tao/Invocation.h
@@ -220,12 +220,6 @@ protected:
ACE_THROW_SPEC ((CORBA::SystemException));
/**
- * Create the IOP::IOR info. We will create the info at most once.
- * Return index of the profile we are using to make the invocation.
- */
- CORBA::ULong create_ior_info (void);
-
- /**
* Add RT-related context to the service context list if the
* invocation target supports RTCORBA::CLIENT_PROPAGATED priority
* model.
@@ -300,15 +294,6 @@ protected:
//@}
/**
- * The ior info. This is needed for GIOP 1.2, as the clients could
- * receive an exception from the server asking for this info. The
- * exception that the client receives is LOC_NEEDS_ADDRESSING_MODE.
- * If we receive an exception we will fill up this data at most
- * *once* and send it to the server.
- */
- IOP::IOR ior_info_;
-
- /**
* Flag indicating whether RTCORBA-specific service context list
* processing has taken place. This is needed because
* prepare_header() may get called multiple times, but we only need
diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp
index dee76e252d0..cf249d44dde 100644
--- a/TAO/tao/Stub.cpp
+++ b/TAO/tao/Stub.cpp
@@ -59,7 +59,9 @@ TAO_Stub::TAO_Stub (const char *repository_id,
#if (TAO_HAS_CORBA_MESSAGING == 1)
policies_ (0),
#endif /* TAO_HAS_CORBA_MESSAGING == 1 */
- addressing_mode_ (0)
+ addressing_mode_ (0),
+ ior_info_ (0),
+ forwarded_ior_info_ (0)
{
if (this->orb_core_ == 0)
{
@@ -177,6 +179,111 @@ TAO_Stub::add_forward_profiles (const TAO_MProfile &mprofiles)
}
+int
+TAO_Stub::create_ior_info (IOP::IOR *ior_info,
+ CORBA::ULong &index,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ // We are creating the IOR info. Let us not be disturbed. So grab a
+ // lock.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->profile_lock_ptr_,
+ -1));
+
+ IOP::IOR *tmp_info = 0;
+
+ if (this->forward_profiles_ != 0)
+ {
+ if (this->forwarded_ior_info_ == 0)
+ {
+ this->get_profile_ior_info (*this->forward_profiles_,
+ tmp_info,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (-1);
+
+ this->forwarded_ior_info_ = tmp_info;
+ }
+
+ // First we look at the forward profiles to see whether the
+ // profile_in_use is any of it.
+ for (CORBA::ULong i = 0;
+ i < this->forward_profiles_->profile_count ();
+ ++i)
+ {
+ if (this->forward_profiles_->get_profile (i)
+ == this->profile_in_use_)
+ {
+ ior_info = this->forwarded_ior_info_;
+ index = i;
+ return 0;
+ }
+ }
+ }
+
+ // Else we look at the base profiles
+ if (this->ior_info_ == 0)
+ {
+ this->get_profile_ior_info (this->base_profiles_,
+ tmp_info,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (-1);
+
+ this->ior_info_ = tmp_info;
+ }
+
+
+ for (CORBA::ULong ind = 0;
+ ind < this->base_profiles_.profile_count ();
+ ++ind)
+ {
+ if (this->base_profiles_.get_profile (ind) ==
+ this->profile_in_use_)
+ {
+ index = ind;
+ ior_info = this->ior_info_;
+ return 0;
+ }
+ }
+
+ // Error, there was no match
+ return -1;
+}
+
+
+int
+TAO_Stub::get_profile_ior_info (TAO_MProfile &profiles,
+ IOP::IOR *&ior_info,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+
+
+ ACE_NEW_THROW_EX (ior_info,
+ IOP::IOR (),
+ CORBA::NO_MEMORY ());
+ ACE_CHECK_RETURN (-1);
+
+
+ // Get the number of elements
+ CORBA::ULong count = profiles.profile_count ();
+
+ // Set the number of elements in the sequence of tagged_profile
+ ior_info->profiles.length (count);
+
+ // Call the create_tagged_profile one every member of the
+ // profile and make the sequence
+ for (CORBA::ULong index = 0; index < count; ++index)
+ {
+ TAO_Profile *prof = profiles.get_profile (index);
+
+ ior_info->profiles[index] = prof->create_tagged_profile ();
+ }
+
+ return 0;
+}
+
// Quick'n'dirty hash of objref data, for partitioning objrefs into
diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h
index 6694cbe36a2..693ed5fb461 100644
--- a/TAO/tao/Stub.h
+++ b/TAO/tao/Stub.h
@@ -258,6 +258,9 @@ public:
/// Obtain a reference to the basic profile set.
TAO_MProfile& base_profiles (void);
+ /// Obtain a pointer to the forwarded profile set
+ const TAO_MProfile *forward_profiles (void) const;
+
// Manage forward and base profiles.
/**
* THREAD SAFE. If forward_profiles is null then this will
@@ -339,6 +342,15 @@ public:
/// preferences on selecting the right profiles.
CORBA::Boolean service_profile_selection (void);
+ /**
+ * Create the IOP::IOR info. We will create the info at most once.
+ * Get the index of the profile we are using to make the invocation.
+ */
+ int create_ior_info (IOP::IOR *ior_info,
+ CORBA::ULong &index,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
private:
/// Makes a copy of the profile and frees the existing profile_in_use.
/// NOT THREAD SAFE
@@ -362,6 +374,12 @@ private:
/// NON-THREAD-SAFE. utility method for next_profile.
TAO_Profile *next_forward_profile (void);
+ /// THREAD-SAFE Create the IOR info
+ int get_profile_ior_info (TAO_MProfile &profile,
+ IOP::IOR *&ior_info,
+ CORBA::Environment &ACE_TRY_ENV)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
#if (TAO_HAS_RT_CORBA == 1)
private:
@@ -438,6 +456,19 @@ private:
/// The addressing mode.
CORBA::Short addressing_mode_;
+ /**
+ * The ior info. This is needed for GIOP 1.2, as the clients could
+ * receive an exception from the server asking for this info. The
+ * exception that the client receives is LOC_NEEDS_ADDRESSING_MODE.
+ * The data is set up here to be passed on to Invocation classes
+ * when they receive an exception. This info is for the base
+ * profiles that this class stores
+ */
+ IOP::IOR *ior_info_;
+
+ /// Forwarded IOR info
+ IOP::IOR *forwarded_ior_info_;
+
// = Disallow copy constructor and assignment operator.
ACE_UNIMPLEMENTED_FUNC (TAO_Stub (const TAO_Stub &))
ACE_UNIMPLEMENTED_FUNC (TAO_Stub &operator = (const TAO_Stub &))
diff --git a/TAO/tao/Stub.i b/TAO/tao/Stub.i
index e9e4c5be6ec..dae3d044b8d 100644
--- a/TAO/tao/Stub.i
+++ b/TAO/tao/Stub.i
@@ -241,6 +241,12 @@ TAO_Stub::base_profiles (void)
return this->base_profiles_;
}
+ACE_INLINE const TAO_MProfile *
+TAO_Stub::forward_profiles (void) const
+{
+ return this->forward_profiles_;
+}
+
ACE_INLINE TAO_ORB_Core*
TAO_Stub::orb_core (void) const