summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-05-25 19:52:46 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-05-25 19:52:46 +0000
commite3110c88e51c35d78a56c743d04f68078ef355b8 (patch)
tree52ff35c382402e3b3e949f5eb51dfb0aa76383a3
parent6192d98362d99bd5d9f8d2749341f46c76178fcb (diff)
downloadATCD-e3110c88e51c35d78a56c743d04f68078ef355b8.tar.gz
The demarshaling operator for >> supports any protocol now.
It delegates on the TAO_Connector_Registry to find the right connector, create the corresponding Profile and decode the CDR stream. It also supports unknown profiles, so we don't loose information when foreign IORs pass through TAO. Also moved common methods in UIOP and IIOP profile to the base class and cleaned up some interfaces.
-rw-r--r--TAO/tao/Connector_Registry.cpp55
-rw-r--r--TAO/tao/Connector_Registry.h3
-rw-r--r--TAO/tao/IIOP_Connector.cpp51
-rw-r--r--TAO/tao/IIOP_Connector.h20
-rw-r--r--TAO/tao/IIOP_Profile.cpp103
-rw-r--r--TAO/tao/IIOP_Profile.h21
-rw-r--r--TAO/tao/Object.cpp101
-rw-r--r--TAO/tao/Object.h24
-rw-r--r--TAO/tao/Pluggable.cpp129
-rw-r--r--TAO/tao/Pluggable.h133
-rw-r--r--TAO/tao/Pluggable.i3
-rw-r--r--TAO/tao/UIOP_Connector.cpp52
-rw-r--r--TAO/tao/UIOP_Connector.h21
-rw-r--r--TAO/tao/UIOP_Profile.cpp238
-rw-r--r--TAO/tao/UIOP_Profile.h21
15 files changed, 504 insertions, 471 deletions
diff --git a/TAO/tao/Connector_Registry.cpp b/TAO/tao/Connector_Registry.cpp
index 12abdac641a..b1e9aa30443 100644
--- a/TAO/tao/Connector_Registry.cpp
+++ b/TAO/tao/Connector_Registry.cpp
@@ -154,6 +154,61 @@ TAO_Connector_Registry::make_mprofile (const char *ior,
// URL style IOR into an MProfile.
}
+TAO_Profile*
+TAO_Connector_Registry::create_profile (TAO_InputCDR& cdr)
+{
+ CORBA::ULong tag;
+
+ // If there is an error we abort
+ if ((cdr >> tag) == 0)
+ return 0;
+
+ TAO_Connector *connector =
+ this->get_connector (tag);
+
+ if (connector == 0)
+ {
+ if (TAO_debug_level > 0)
+ {
+ // @@ TODO create a generic profile in this case...
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) unknown profile tag %d\n",
+ tag));
+ }
+
+ TAO_Profile* pfile;
+ ACE_NEW_RETURN (pfile, TAO_Unknown_Profile (tag), 0);
+
+ if (pfile->decode (cdr) == -1)
+ {
+ pfile->_decr_refcnt ();
+ pfile = 0;
+ }
+ return pfile;
+ }
+
+ // OK, we've got known profile.
+ // It's going to be encapsulated ProfileData.
+ // Create a new decoding stream and context for it, and skip the
+ // data in the parent stream
+
+ // ProfileData is encoded as a sequence of octet. So first get
+ // the length of the sequence.
+ CORBA::ULong encap_len;
+ if ((cdr >> encap_len) == 0)
+ return 0;
+
+ // Create the decoding stream from the encapsulation in the
+ // buffer, and skip the encapsulation.
+ TAO_InputCDR str (cdr, encap_len);
+
+ if (str.good_bit () == 0
+ || cdr.skip_bytes (encap_len) == 0)
+ return 0;
+
+ return connector->create_profile (str);
+}
+
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Node<TAO_Connector*>;
diff --git a/TAO/tao/Connector_Registry.h b/TAO/tao/Connector_Registry.h
index b556a5bf662..4a0ac03076a 100644
--- a/TAO/tao/Connector_Registry.h
+++ b/TAO/tao/Connector_Registry.h
@@ -86,6 +86,9 @@ public:
// Parse a string containing a URL style IOR and return an
// MProfile.
+ TAO_Profile* create_profile (TAO_InputCDR& cdr);
+ // Create a profile based on the contents of <cdr>
+
private:
TAO_ConnectorSet connectors_;
// list of connectors currently open.
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index 1e42eba5b1c..47d484940c3 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -27,6 +27,23 @@ TAO_IIOP_Connector::TAO_IIOP_Connector (void)
}
int
+TAO_IIOP_Connector::open (TAO_Resource_Factory *trf,
+ ACE_Reactor *reactor)
+{
+ return this->base_connector_.open (reactor,
+ trf->get_null_creation_strategy (),
+ trf->get_cached_connect_strategy (),
+ trf->get_null_activation_strategy ());
+}
+
+int
+TAO_IIOP_Connector::close (void)
+{
+ this->base_connector_.close ();
+ return 0;
+}
+
+int
TAO_IIOP_Connector::connect (TAO_Profile *profile,
TAO_Transport *& transport)
{
@@ -68,27 +85,11 @@ TAO_IIOP_Connector::connect (TAO_Profile *profile,
}
int
-TAO_IIOP_Connector::open (TAO_Resource_Factory *trf,
- ACE_Reactor *reactor)
-{
- return this->base_connector_.open (reactor,
- trf->get_null_creation_strategy (),
- trf->get_cached_connect_strategy (),
- trf->get_null_activation_strategy ());
-}
-
-int
-TAO_IIOP_Connector::close (void)
-{
- this->base_connector_.close ();
- return 0;
-}
-
-int
TAO_IIOP_Connector::preconnect (const char *preconnects)
{
char *preconnections = ACE_OS::strdup (preconnects);
+ // @@ Fred&Ossama: cleanup this code before the merge!
#if 0
if (preconnections)
{
@@ -217,6 +218,22 @@ TAO_IIOP_Connector::preconnect (const char *preconnects)
return successes;
}
+TAO_Profile*
+TAO_IIOP_Connector::create_profile (TAO_InputCDR& cdr)
+{
+ TAO_Profile* pfile;
+ ACE_NEW_RETURN (pfile, TAO_IIOP_Profile, 0);
+
+ int r = pfile->decode (cdr);
+ if (r == -1)
+ {
+ pfile->_decr_refcnt ();
+ pfile = 0;
+ }
+
+ return pfile;
+}
+
int
TAO_IIOP_Connector::make_profile (const char *endpoint,
TAO_Profile *&profile,
diff --git a/TAO/tao/IIOP_Connector.h b/TAO/tao/IIOP_Connector.h
index 4cd4dcc90fb..099a33e312e 100644
--- a/TAO/tao/IIOP_Connector.h
+++ b/TAO/tao/IIOP_Connector.h
@@ -35,33 +35,27 @@ class TAO_Export TAO_IIOP_Connector : public TAO_Connector
//
// = DESCRIPTION
// @@ Fred, please fill in here.
+ //
public:
// = Initialization and termination methods.
TAO_IIOP_Connector (void);
// Constructor.
+ // = The TAO_Connector methods, please check the documentation on
+ // Pluggable.h
int open (TAO_Resource_Factory *trf, ACE_Reactor *reactor);
- // Initialize object and register with reactor.
-
int close (void);
- // Shutdown Connector bridge and concreate Connector.
-
+ int connect (TAO_Profile *profile, TAO_Transport *&transport);
int preconnect (const char *preconnections);
- // Initial set of connections to be established.
-
- int connect (TAO_Profile *profile,
- TAO_Transport *&transport);
- // Connect will be called from TAO_GIOP_Invocation::start
+ TAO_Profile *create_profile (TAO_InputCDR& cdr);
protected:
+ // = More TAO_Connector methods, please check the documentation on
+ // Pluggable.h
virtual int make_profile (const char *endpoint,
TAO_Profile *&,
CORBA::Environment &ACE_TRY_ENV);
- // Create a profile with a given endpoint.
-
virtual int check_prefix (const char *endpoint);
- // Check that the prefix of the provided endpoint is valid for use
- // with a given pluggable protocol.
private:
TAO_IIOP_BASE_CONNECTOR base_connector_;
diff --git a/TAO/tao/IIOP_Profile.cpp b/TAO/tao/IIOP_Profile.cpp
index 69acc07eeaf..99dcda1c4a6 100644
--- a/TAO/tao/IIOP_Profile.cpp
+++ b/TAO/tao/IIOP_Profile.cpp
@@ -27,9 +27,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr,
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set(addr);
int l = ACE_OS::strlen (object_key);
@@ -50,9 +48,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr,
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (object_key),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set(addr);
this->create_body ();
@@ -68,9 +64,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr,
version_ (version),
object_key_ (),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set(addr);
int l = ACE_OS::strlen (object_key);
@@ -92,9 +86,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const ACE_INET_Addr& addr,
version_ (version),
object_key_ (object_key),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set(addr);
this->create_body ();
@@ -110,9 +102,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host,
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (object_key),
object_addr_ (port, host),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
if (host)
@@ -136,9 +126,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host,
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (object_key),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
if (host)
@@ -162,9 +150,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char* host,
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (object_key),
object_addr_ (port, host),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
ACE_UNUSED_ARG (version);
@@ -183,9 +169,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const TAO_IIOP_Profile *pfile)
version_(pfile->version_),
object_key_(pfile->object_key_),
object_addr_(pfile->object_addr_),
- hint_(0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_(0)
{
ACE_NEW (this->host_,
@@ -203,9 +187,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const TAO_IIOP_Profile &pfile)
version_(pfile.version_),
object_key_(pfile.object_key_),
object_addr_(pfile.object_addr_),
- hint_(0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_(0)
{
ACE_NEW (this->host_,
@@ -223,9 +205,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const TAO_IOP_Version &version)
version_ (version),
object_key_ (),
object_addr_ (),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
}
@@ -238,9 +218,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (const char *string,
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (),
object_addr_ (),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
parse_string (string, env);
}
@@ -253,9 +231,7 @@ TAO_IIOP_Profile::TAO_IIOP_Profile (void)
version_ (DEF_IIOP_MAJOR, DEF_IIOP_MINOR),
object_key_ (),
object_addr_ (),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
}
@@ -293,8 +269,6 @@ TAO_IIOP_Profile::set (const ACE_INET_Addr& addr)
TAO_IIOP_Profile::~TAO_IIOP_Profile (void)
{
- assert (this->refcount_ == 0);
-
delete [] this->host_;
this->host_ = 0;
}
@@ -304,9 +278,7 @@ TAO_IIOP_Profile::~TAO_IIOP_Profile (void)
// 0 -> can't understand this version
// 1 -> success.
int
-TAO_IIOP_Profile::parse (TAO_InputCDR& cdr,
- CORBA::Boolean &continue_decoding,
- CORBA::Environment &env)
+TAO_IIOP_Profile::decode (TAO_InputCDR& cdr)
{
CORBA::ULong encap_len = cdr.length ();
@@ -323,11 +295,13 @@ TAO_IIOP_Profile::parse (TAO_InputCDR& cdr,
&& cdr.read_octet (this->version_.minor)
&& this->version_.minor <= TAO_IIOP_Profile::DEF_IIOP_MINOR))
{
- ACE_DEBUG ((LM_DEBUG,
- "detected new v%d.%d IIOP profile",
- this->version_.major,
- this->version_.minor));
- return 0;
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) IIOP_Profile::decode - v%d.%d\n",
+ this->version_.major,
+ this->version_.minor));
+ }
}
if (this->host_)
@@ -340,7 +314,12 @@ TAO_IIOP_Profile::parse (TAO_InputCDR& cdr,
if (cdr.read_string (this->host_) == 0
|| cdr.read_ushort (this->port_) == 0)
{
- ACE_DEBUG ((LM_DEBUG, "error decoding IIOP host/port"));
+ if (TAO_debug_level > 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) IIOP_Profile::decode - "
+ "error while decoding host/port"));
+ }
return -1;
}
@@ -607,36 +586,6 @@ TAO_IIOP_Profile::operator= (const TAO_IIOP_Profile &src)
return *this;
}
-// Memory managment
-
-CORBA::ULong
-TAO_IIOP_Profile::_incr_refcnt (void)
-{
- // OK, think I got it. When this object is created (guard) the
- // lock is automatically acquired (refcount_lock_). Then when
- // we leave this method the destructir for guard is called which
- // releases the lock!
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
-
- return this->refcount_++;
-}
-
-CORBA::ULong
-TAO_IIOP_Profile::_decr_refcnt (void)
-{
- {
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->refcount_lock_, 0);
- this->refcount_--;
- if (this->refcount_ != 0)
- return this->refcount_;
- }
-
- // refcount is 0, so delete us!
- // delete will call our ~ destructor which in turn deletes stuff.
- delete this;
- return 0;
-}
-
CORBA::String
TAO_IIOP_Profile::to_string (CORBA::Environment &env)
{
diff --git a/TAO/tao/IIOP_Profile.h b/TAO/tao/IIOP_Profile.h
index 69288f628fe..8d0b9a42b10 100644
--- a/TAO/tao/IIOP_Profile.h
+++ b/TAO/tao/IIOP_Profile.h
@@ -108,11 +108,6 @@ public:
~TAO_IIOP_Profile (void);
// Destructor is to be called only through <_decr_refcnt>.
- int parse (TAO_InputCDR& cdr,
- CORBA::Boolean& continue_decoding,
- CORBA::Environment &env);
- // Initialize this object using the given CDR octet string.
-
int parse_string (const char *string,
CORBA::Environment &env);
// Initialize this object using the given input string.
@@ -124,6 +119,9 @@ public:
const TAO_opaque& body (void) const;
// Create IIOP_Profile Object from marshalled data.
+ int decode (TAO_InputCDR& cdr);
+ // Initialize this object using the given CDR octet string.
+
virtual int encode (TAO_OutputCDR &stream) const;
// Encode this profile in a stream, i.e. marshal it.
@@ -186,13 +184,6 @@ public:
TAO_IIOP_Profile &operator= (const TAO_IIOP_Profile &src);
// Copy operator.
- virtual CORBA::ULong _incr_refcnt (void);
- // Increase the reference count by one on this object.
-
- virtual CORBA::ULong _decr_refcnt (void);
- // Decrement the object's reference count. When this count goes to
- // 0 this object will be deleted.
-
private:
int set (const ACE_INET_Addr &addr);
// helper method to set the INET_Addr.
@@ -224,12 +215,6 @@ private:
TAO_Client_Connection_Handler *hint_;
// Pointer to a connection handler which we successfully used
// already.
-
- ACE_SYNCH_MUTEX refcount_lock_;
- // Mutex to protect reference count.
-
- CORBA::ULong refcount_;
- // Number of outstanding references to this object.
};
#if defined (__ACE_INLINE__)
diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp
index 2c6a78db69a..7188a3cc12c 100644
--- a/TAO/tao/Object.cpp
+++ b/TAO/tao/Object.cpp
@@ -495,101 +495,22 @@ operator>> (TAO_InputCDR& cdr, CORBA_Object*& x)
// get a profile container to store all profiles in the IOR.
TAO_MProfile mp (profile_count);
- while (profile_count-- != 0 && cdr.good_bit ())
+ TAO_Connector_Registry *connector_registry =
+ cdr.orb_core ()->connector_registry ();
+ for (CORBA::ULong i = 0; i != profile_count && cdr.good_bit (); ++i)
{
- CORBA::ULong tag;
-
- // If there is an error we abort
- if ((cdr >> tag) == 0)
- continue;
-
- // @@ For now we just take IIOP_Profiles, FRED
- // @@ fred: this is something that we *must* handle correctly,
- // the TAO_Profile class must be concrete (or we must have a
- // TAO_Generic_Profile class), any profile we don't anything
- // about should be converted in one of those
- // TAO_Generic_Profiles.
- // Also: the right component to decide if we can handle a
- // profile or not is the connector registry.
- // Carlos.
- //
- if (tag != TAO_IOP_TAG_INTERNET_IOP)
- {
- ACE_DEBUG ((LM_DEBUG,
- "unknown profile tag %d skipping\n", tag));
- cdr.skip_string ();
- continue;
- }
-
- // OK, we've got an IIOP profile. It's going to be
- // encapsulated ProfileData. Create a new decoding stream and
- // context for it, and tell the "parent" stream that this data
- // isn't part of it any more.
-
- // ProfileData is encoded as a sequence of octet. So first get
- // the length of the sequence.
- CORBA::ULong encap_len;
- if ((cdr >> encap_len) == 0)
- continue;
-
- // Create the decoding stream from the encapsulation in the
- // buffer, and skip the encapsulation.
- TAO_InputCDR str (cdr, encap_len);
-
- if (str.good_bit () == 0
- || cdr.skip_bytes (encap_len) == 0)
- continue;
-
- // get the default IIOP Profile and fill in the blanks
- // with str.
- // @@ use an auto_ptr<> here!
- TAO_IIOP_Profile *pfile;
- ACE_NEW_RETURN (pfile, TAO_IIOP_Profile, 0);
-
- int r = 0;
- ACE_TRY_NEW_ENV
- {
- CORBA::Boolean continue_decoding;
- r = pfile->parse (str, continue_decoding, ACE_TRY_ENV);
- ACE_TRY_CHECK;
- }
- ACE_CATCHANY
- {
- ACE_ERROR ((LM_ERROR,
- "IIOP_Profile::parse raised exception!"
- " Shouldn't happen\n"));
- ACE_TRY_ENV.print_exception ("IIOP_Profile::parse");
- pfile->_decr_refcnt ();
- return 0;
- }
- ACE_ENDTRY;
-
- switch (r)
- {
- case -1:
- pfile->_decr_refcnt ();
- return 0;
- case 0:
- pfile->_decr_refcnt ();
- break;
- case 1:
- default:
- mp.give_profile (pfile);
- // all other return values indicate success
- // we do not decrement reference count on profile since we
- // are giving it to the MProfile!
- break;
- } // switch
-
- } // while loop
+ TAO_Profile *pfile =
+ connector_registry->create_profile (cdr);
+ if (pfile != 0)
+ mp.give_profile (pfile);
+ }
// make sure we got some profiles!
- if (mp.profile_count () == 0)
+ if (mp.profile_count () != profile_count)
{
ACE_DEBUG ((LM_DEBUG,
- "no IIOP v%d.%d (or earlier) profile in IOR!\n",
- TAO_IIOP_Profile::DEF_IIOP_MAJOR,
- TAO_IIOP_Profile::DEF_IIOP_MINOR));
+ "TAO (%P|%t) could not create all "
+ "the profiles\n"));
return 0;
}
diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h
index e35974ef463..667cada58df 100644
--- a/TAO/tao/Object.h
+++ b/TAO/tao/Object.h
@@ -43,7 +43,7 @@ public:
// return a NUL object
static CORBA_Object_ptr _narrow (CORBA_Object_ptr obj,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// no-op it is just here to simplify some templates.
@@ -54,7 +54,7 @@ public:
// appropriate.
virtual CORBA::Boolean _is_a (const CORBA::Char *logical_type_id,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// determine if we are of the type specified by the "logical_type_id"
@@ -68,18 +68,18 @@ public:
virtual CORBA::Boolean _is_collocated (void) const;
// are we collocated with the servant?
- virtual CORBA::Boolean _non_existent (CORBA_Environment &TAO_IN_ENV =
+ virtual CORBA::Boolean _non_existent (CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
#if !defined (TAO_HAS_MINIMUM_CORBA)
virtual CORBA::ImplementationDef_ptr
- _get_implementation (CORBA_Environment &TAO_IN_ENV =
+ _get_implementation (CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// This method is deprecated in the CORBA 2.2 spec, we just return 0
// every time.
- virtual CORBA::InterfaceDef_ptr _get_interface (CORBA_Environment &TAO_IN_ENV =
+ virtual CORBA::InterfaceDef_ptr _get_interface (CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// Interface repository related operations.
@@ -96,7 +96,7 @@ public:
CORBA::NamedValue_ptr result,
CORBA::Request_ptr &request,
CORBA::Flags req_flags,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
virtual void _create_request (CORBA::Context_ptr ctx,
@@ -107,7 +107,7 @@ public:
CORBA::ContextList_ptr ctxtlist,
CORBA::Request_ptr &request,
CORBA::Flags req_flags,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// The default implementation of this method uses the same simple,
@@ -115,7 +115,7 @@ public:
// calls above ... that's how it can have a default implementation.
virtual CORBA::Request_ptr _request (const CORBA::Char *operation,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// DII operation to create a request.
@@ -151,7 +151,7 @@ public:
#endif /* TAO_HAS_CORBA_MESSAGING */
virtual CORBA::ULong _hash (CORBA::ULong maximum,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// Return a (potentially non-unique) hash value for this object.
// This method relies on the representation of the object
@@ -160,14 +160,14 @@ public:
// implementation.
virtual CORBA::Boolean _is_equivalent (CORBA::Object_ptr other_obj,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// Try to determine if this object is the same as <other_obj>. This
// method relies on the representation of the object reference's
// private state. Since that changes easily (when different ORB
// protocols are in use) there is no default implementation.
- virtual TAO_ObjectKey *_key (CORBA_Environment &TAO_IN_ENV =
+ virtual TAO_ObjectKey *_key (CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ());
// Return the object key as an out parameter. Caller should release
// return value when finished with it.
@@ -292,7 +292,7 @@ public:
// destructor
virtual void _downcast (CORBA_Object* base_ptr,
- CORBA_Environment &TAO_IN_ENV =
+ CORBA_Environment &TAO_IN_ENV =
CORBA::default_environment ()) = 0;
virtual CORBA_Object* _upcast (void) = 0;
virtual void _release (void) = 0;
diff --git a/TAO/tao/Pluggable.cpp b/TAO/tao/Pluggable.cpp
index 81890f3c401..304cacc572c 100644
--- a/TAO/tao/Pluggable.cpp
+++ b/TAO/tao/Pluggable.cpp
@@ -5,6 +5,9 @@
#include "tao/Stub.h"
#include "tao/Environment.h"
#include "tao/GIOP.h"
+#include "tao/CDR.h"
+#include "tao/Object_KeyC.h"
+#include "ace/ACE.h"
TAO_IOP_Version::~TAO_IOP_Version (void)
{
@@ -49,6 +52,12 @@ TAO_IOP_Version::operator= (const TAO_IOP_Version &src)
return *this;
}
+// ****************************************************************
+
+TAO_Profile::~TAO_Profile (void)
+{
+}
+
// Generic Profile
CORBA::ULong
TAO_Profile::tag (void) const
@@ -56,10 +65,128 @@ TAO_Profile::tag (void) const
return this->tag_;
}
-TAO_Profile::~TAO_Profile (void)
+CORBA::ULong
+TAO_Profile::_incr_refcnt (void)
{
+ // OK, think I got it. When this object is created (guard) the
+ // lock is automatically acquired (refcount_lock_). Then when
+ // we leave this method the destructir for guard is called which
+ // releases the lock!
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
+
+ return this->refcount_++;
}
+CORBA::ULong
+TAO_Profile::_decr_refcnt (void)
+{
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->refcount_lock_, 0);
+ this->refcount_--;
+ if (this->refcount_ != 0)
+ return this->refcount_;
+ }
+
+ // refcount is 0, so delete us!
+ // delete will call our ~ destructor which in turn deletes stuff.
+ delete this;
+ return 0;
+}
+
+// ****************************************************************
+
+TAO_Unknown_Profile::TAO_Unknown_Profile (CORBA::ULong tag)
+ : TAO_Profile (tag)
+{
+}
+
+int
+TAO_Unknown_Profile::parse_string (const char *,
+ CORBA::Environment &)
+{
+ // @@ THROW something????
+ return -1;
+}
+
+CORBA::String
+TAO_Unknown_Profile::to_string (CORBA::Environment &)
+{
+ // @@ THROW something?
+ return 0;
+}
+
+const TAO_opaque&
+TAO_Unknown_Profile::body (void) const
+{
+ return this->body_;
+}
+
+int
+TAO_Unknown_Profile::decode (TAO_InputCDR& cdr)
+{
+ if ((cdr >> this->body_) == 0)
+ return -1;
+ return 0;
+}
+
+int
+TAO_Unknown_Profile::encode (TAO_OutputCDR &stream) const
+{
+ stream.write_ulong (this->tag ());
+ return (stream << this->body_);
+}
+
+const TAO_ObjectKey &
+TAO_Unknown_Profile::object_key (void) const
+{
+ // @@ TODO this is wrong, but the function is deprecated anyway....
+ static TAO_ObjectKey empty_key;
+ return empty_key;
+}
+
+TAO_ObjectKey *
+TAO_Unknown_Profile::_key (CORBA::Environment &) const
+{
+ // @@ THROW something???
+ return 0;
+}
+
+CORBA::Boolean
+TAO_Unknown_Profile::is_equivalent (TAO_Profile* other_profile,
+ CORBA::Environment &)
+{
+ if (other_profile->tag () != this->tag ())
+ return 0;
+
+ TAO_Unknown_Profile *op =
+ ACE_dynamic_cast (TAO_Unknown_Profile*, other_profile);
+
+ return (this->body_ == op->body_);
+}
+
+CORBA::ULong
+TAO_Unknown_Profile::hash (CORBA::ULong max,
+ CORBA::Environment &)
+{
+ return (ACE::hash_pjw (ACE_reinterpret_cast (const char*,
+ this->body_.get_buffer ()),
+ this->body_.length ()) % max);
+}
+
+ASYS_TCHAR *
+TAO_Unknown_Profile::addr_to_string(void)
+{
+ return 0;
+}
+
+void
+TAO_Unknown_Profile::reset_hint (void)
+{
+ // do nothing
+}
+
+// ****************************************************************
+
// Transport ...
TAO_Transport::TAO_Transport (CORBA::ULong tag)
: tag_ (tag)
diff --git a/TAO/tao/Pluggable.h b/TAO/tao/Pluggable.h
index d65050be875..67af58c7372 100644
--- a/TAO/tao/Pluggable.h
+++ b/TAO/tao/Pluggable.h
@@ -21,6 +21,7 @@
#define TAO_PLUGGABLE_H
#include "tao/corbafwd.h"
+#include "tao/Sequence.h"
// Forward declarations.
class ACE_Addr;
@@ -169,7 +170,7 @@ public:
class TAO_Export TAO_Profile
{
// = TITLE
- // Generic Profile definitions.
+ // Defines the Profile interface
//
// = DESCRIPTION
// An abstract base class for representing object address or location
@@ -179,13 +180,28 @@ public:
TAO_Profile (CORBA::ULong tag);
// Constructor
+ virtual ~TAO_Profile (void);
+ // If you have a virtual method you need a virtual dtor.
+
CORBA::ULong tag (void) const;
// The tag, each concrete class will have a specific tag value.
- virtual int parse (TAO_InputCDR& cdr,
- CORBA::Boolean& continue_decoding,
- CORBA::Environment &env) = 0;
- // Initialize this object using the given CDR octet string.
+ CORBA::ULong _incr_refcnt (void);
+ // Increase the reference count by one on this object.
+
+ CORBA::ULong _decr_refcnt (void);
+ // Decrement the object's reference count. When this count goes to
+ // 0 this object will be deleted.
+ // @@ Fred&Ossama: guys, reference counting *should* be implemented
+ // in the base class, otherwise you are just going to end up
+ // repeating code and forcing the user to implement things not
+ // directly related to protocols.
+
+ void forward_to (TAO_MProfile *mprofiles);
+ // Keep a pointer to the forwarded profile
+
+ TAO_MProfile* forward_to (void);
+ // MProfile accessor
virtual int parse_string (const char *string,
CORBA::Environment &env) = 0;
@@ -209,6 +225,9 @@ public:
//
// will work better.
+ virtual int decode (TAO_InputCDR& cdr) = 0;
+ // Initialize this object using the given CDR octet string.
+
virtual int encode (TAO_OutputCDR &stream) const = 0;
// Encode this profile in a stream, i.e. marshal it.
@@ -222,12 +241,6 @@ public:
// Obtain the object key, return 0 if the profile cannot be parsed.
// The memory is owned by the caller!
- void forward_to (TAO_MProfile *mprofiles);
- // Keep a pointer to the forwarded profile
-
- TAO_MProfile* forward_to (void);
- // MProfile accessor
-
virtual CORBA::Boolean is_equivalent (TAO_Profile* other_profile,
CORBA::Environment &env) = 0;
// Return true if this profile is equivalent to other_profile. Two
@@ -246,19 +259,9 @@ public:
// This method is used with a connection has been reset requiring
// the hint to be cleaned up and reset to NULL.
- virtual CORBA::ULong _incr_refcnt (void) = 0;
- // Increase the reference count by one on this object.
-
- virtual CORBA::ULong _decr_refcnt (void) = 0;
- // Decrement the object's reference count. When this count goes to
- // 0 this object will be deleted.
- // @@ Fred&Ossama: guys, reference counting *should* be implemented
- // in the base class, otherwise you are just going to end up
- // repeating code and forcing the user to implement things not
- // directly related to protocols.
-
- virtual ~TAO_Profile (void);
- // If you have a virtual method you need a virtual dtor.
+private:
+ TAO_MProfile *forward_to_i (void);
+ // this object keeps ownership of this object
private:
CORBA::ULong tag_;
@@ -268,13 +271,53 @@ private:
// the TAO_MProfile which contains the profiles for the forwarded
// object.
-private:
+ ACE_SYNCH_MUTEX refcount_lock_;
+ // Mutex to protect reference count.
- TAO_MProfile *forward_to_i (void);
- // this object keeps ownership of this object
+ CORBA::ULong refcount_;
+ // Number of outstanding references to this object.
+};
+
+class TAO_Export TAO_Unknown_Profile : public TAO_Profile
+{
+ // = TITLE
+ // A TAO_Profile class to handle foreign profiles.
+ //
+ // = DESCRIPTION
+ // The CORBA spec implies that ORBs must be prepared to save and
+ // pass around profiles for protocols it does not recognize. It is
+ // not mandatory to *use* those profiles but they shouldn't be
+ // dropped.
+ // This class stores the information required to marshal and
+ // demarshal an unknown profile, but simply returns an error if
+ // any of the TAO internal methods are invoked.
+ //
+public:
+ TAO_Unknown_Profile (CORBA::ULong tag);
+ // Create the profile
+ // = The TAO_Profile methods look above
+ virtual int parse_string (const char *string,
+ CORBA::Environment &env);
+ virtual CORBA::String to_string (CORBA::Environment &env);
+ virtual const TAO_opaque &body (void) const;
+ virtual int decode (TAO_InputCDR& cdr);
+ virtual int encode (TAO_OutputCDR &stream) const;
+ virtual const TAO_ObjectKey &object_key (void) const;
+ virtual TAO_ObjectKey *_key (CORBA::Environment &env) const;
+ virtual CORBA::Boolean is_equivalent (TAO_Profile* other_profile,
+ CORBA::Environment &env);
+ virtual CORBA::ULong hash (CORBA::ULong max,
+ CORBA::Environment &env);
+ virtual ASYS_TCHAR *addr_to_string(void);
+ virtual void reset_hint (void);
+
+private:
+ TAO_opaque body_;
};
+// ****************************************************************
+
class TAO_Export TAO_Acceptor
{
// = TITLE
@@ -327,15 +370,8 @@ public:
TAO_Connector (CORBA::ULong tag);
// default constructor.
- virtual int preconnect (const char *preconnections) = 0;
- // Initial set of connections to be established.
-
- virtual int open (TAO_Resource_Factory *trf,
- ACE_Reactor *reactor) = 0;
- // Initialize object and register with reactor.
-
- virtual int close (void) = 0;
- // Shutdown Connector bridge and concreate Connector.
+ virtual ~TAO_Connector (void);
+ // the destructor.
CORBA::ULong tag (void) const;
// The tag identifying the specific ORB transport layer protocol.
@@ -344,20 +380,31 @@ public:
// profile0} {tag1, profole1} ...} GIOP.h defines typedef
// CORBA::ULong TAO_IOP_Profile_ID;
+ int make_mprofile (const char *ior,
+ TAO_MProfile &mprofile,
+ CORBA::Environment &ACE_TRY_ENV);
+ // Parse a string containing a URL style IOR and return an
+ // MProfile.
+
+ virtual int open (TAO_Resource_Factory *trf,
+ ACE_Reactor *reactor) = 0;
+ // Initialize object and register with reactor.
+
+ virtual int close (void) = 0;
+ // Shutdown Connector bridge and concreate Connector.
+
virtual int connect (TAO_Profile *profile,
TAO_Transport *&) = 0;
// To support pluggable we need to abstract away the connect()
// method so it can be called from the GIOP code independant of the
// actual transport protocol in use.
- int make_mprofile (const char *ior,
- TAO_MProfile &mprofile,
- CORBA::Environment &ACE_TRY_ENV);
- // Parse a string containing a URL style IOR and return an
- // MProfile.
+ virtual int preconnect (const char *preconnections) = 0;
+ // Initial set of connections to be established.
- virtual ~TAO_Connector (void);
- // the destructor.
+ virtual TAO_Profile *create_profile (TAO_InputCDR& cdr) = 0;
+ // Create a profile for this protocol and initialize it based on the
+ // encapsulation in <cdr>
protected:
virtual int make_profile (const char *endpoint,
diff --git a/TAO/tao/Pluggable.i b/TAO/tao/Pluggable.i
index 40d39d78c45..a4cbf97a151 100644
--- a/TAO/tao/Pluggable.i
+++ b/TAO/tao/Pluggable.i
@@ -4,7 +4,8 @@
ACE_INLINE
TAO_Profile::TAO_Profile (CORBA::ULong tag)
: tag_ (tag),
- forward_to_ (0)
+ forward_to_ (0),
+ refcount_ (1)
{
}
diff --git a/TAO/tao/UIOP_Connector.cpp b/TAO/tao/UIOP_Connector.cpp
index 6b45226303c..2936ceeb125 100644
--- a/TAO/tao/UIOP_Connector.cpp
+++ b/TAO/tao/UIOP_Connector.cpp
@@ -36,6 +36,23 @@ TAO_UIOP_Connector::TAO_UIOP_Connector (void)
}
int
+TAO_UIOP_Connector::open (TAO_Resource_Factory *trf,
+ ACE_Reactor *reactor)
+{
+ return this->base_connector_.open (reactor,
+ &UIOP_Null_Creation_Strategy_,
+ &UIOP_Cached_Connect_Strategy_,
+ &UIOP_Null_Activation_Strategy_);
+}
+
+int
+TAO_UIOP_Connector::close (void)
+{
+ this->base_connector_.close ();
+ return 0;
+}
+
+int
TAO_UIOP_Connector::connect (TAO_Profile *profile,
TAO_Transport *& transport)
{
@@ -77,23 +94,6 @@ TAO_UIOP_Connector::connect (TAO_Profile *profile,
}
int
-TAO_UIOP_Connector::open (TAO_Resource_Factory *trf,
- ACE_Reactor *reactor)
-{
- return this->base_connector_.open (reactor,
- &UIOP_Null_Creation_Strategy_,
- &UIOP_Cached_Connect_Strategy_,
- &UIOP_Null_Activation_Strategy_);
-}
-
-int
-TAO_UIOP_Connector::close (void)
-{
- this->base_connector_.close ();
- return 0;
-}
-
-int
TAO_UIOP_Connector::preconnect (const char *preconnects)
{
char *preconnections = ACE_OS::strdup (preconnects);
@@ -223,6 +223,22 @@ TAO_UIOP_Connector::preconnect (const char *preconnects)
return successes;
}
+TAO_Profile*
+TAO_UIOP_Connector::create_profile (TAO_InputCDR& cdr)
+{
+ TAO_Profile* pfile;
+ ACE_NEW_RETURN (pfile, TAO_UIOP_Profile, 0);
+
+ int r = pfile->decode (cdr);
+ if (r == -1)
+ {
+ pfile->_decr_refcnt ();
+ pfile = 0;
+ }
+
+ return pfile;
+}
+
int
TAO_UIOP_Connector::make_profile (const char *endpoint,
TAO_Profile *&profile,
@@ -234,7 +250,7 @@ TAO_UIOP_Connector::make_profile (const char *endpoint,
//
// or:
//
- // //rendezvous_point/object_key
+ // //rendezvous_point/object_key
ACE_NEW_RETURN (profile,
TAO_UIOP_Profile (endpoint, ACE_TRY_ENV),
diff --git a/TAO/tao/UIOP_Connector.h b/TAO/tao/UIOP_Connector.h
index 9cada4279a0..57757ad5c15 100644
--- a/TAO/tao/UIOP_Connector.h
+++ b/TAO/tao/UIOP_Connector.h
@@ -57,7 +57,7 @@ class TAO_Export TAO_UIOP_Connector : public TAO_Connector
// UIOP-specific Connector bridge for pluggable protocols.
//
// = DESCRIPTION
- //
+ //
public:
// = Initialization and termination methods.
TAO_UIOP_Connector (void);
@@ -65,28 +65,21 @@ public:
// @@ Do we want to pass in the tag here or should it be statically
// defined?
+ // = The TAO_Connector methods, please check the documentation on
+ // Pluggable.h
int open (TAO_Resource_Factory *trf, ACE_Reactor *reactor);
- // Initialize object and register with reactor.
-
int close (void);
- // Shutdown Connector bridge and concreate Connector.
-
+ int connect (TAO_Profile *profile, TAO_Transport *&transport);
int preconnect (const char *preconnections);
- // Initial set of connections to be established.
-
- int connect (TAO_Profile *profile,
- TAO_Transport *&transport);
- // Connect will be called from TAO_GIOP_Invocation::start
+ TAO_Profile *create_profile (TAO_InputCDR& cdr);
protected:
+ // = More TAO_Connector methods, please check the documentation on
+ // Pluggable.h
virtual int make_profile (const char *endpoint,
TAO_Profile *&,
CORBA::Environment &ACE_TRY_ENV);
- // Create a profile with a given endpoint.
-
virtual int check_prefix (const char *endpoint);
- // Check that the prefix of the provided endpoint is valid for use
- // with a given pluggable protocol.
private:
TAO_UIOP_BASE_CONNECTOR base_connector_;
diff --git a/TAO/tao/UIOP_Profile.cpp b/TAO/tao/UIOP_Profile.cpp
index abff059a75f..d012c4a774f 100644
--- a/TAO/tao/UIOP_Profile.cpp
+++ b/TAO/tao/UIOP_Profile.cpp
@@ -28,9 +28,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr,
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set (addr);
int l = ACE_OS::strlen (object_key);
@@ -50,9 +48,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr,
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (object_key),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set (addr);
this->create_body ();
@@ -67,9 +63,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr,
version_ (version),
object_key_ (),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set (addr);
int l = ACE_OS::strlen (object_key);
@@ -90,9 +84,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const ACE_UNIX_Addr& addr,
version_ (version),
object_key_ (object_key),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
this->set (addr);
this->create_body ();
@@ -106,9 +98,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char* rendezvous_point,
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (object_key),
object_addr_ (rendezvous_point),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
if (rendezvous_point)
@@ -130,9 +120,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char* rendezvous_point,
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (object_key),
object_addr_ (addr),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
if (rendezvous_point)
@@ -154,9 +142,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char* rendezvous_point,
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (object_key),
object_addr_ (rendezvous_point),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
ACE_UNUSED_ARG (version);
@@ -174,9 +160,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const TAO_UIOP_Profile *pfile)
version_(pfile->version_),
object_key_(pfile->object_key_),
object_addr_(pfile->object_addr_),
- hint_(0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_(0)
{
ACE_NEW (this->rendezvous_point_,
@@ -193,9 +177,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const TAO_UIOP_Profile &pfile)
version_(pfile.version_),
object_key_(pfile.object_key_),
object_addr_(pfile.object_addr_),
- hint_(0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_(0)
{
ACE_NEW (this->rendezvous_point_,
@@ -212,9 +194,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const TAO_IOP_Version &version)
version_ (version),
object_key_ (),
object_addr_ (),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
}
@@ -226,9 +206,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (const char *string,
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (),
object_addr_ (),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
parse_string (string, env);
}
@@ -240,9 +218,7 @@ TAO_UIOP_Profile::TAO_UIOP_Profile (void)
version_ (DEF_UIOP_MAJOR, DEF_UIOP_MINOR),
object_key_ (),
object_addr_ (),
- hint_ (0),
- // what about refcount_lock_ (),
- refcount_ (1)
+ hint_ (0)
{
}
@@ -265,95 +241,16 @@ TAO_UIOP_Profile::set (const ACE_UNIX_Addr& addr)
// " rendezvous_point: <%s>\n",
// temp_rendezvous_point,
// this->rendezvous_point_));
-
+
return 0; // Success
}
TAO_UIOP_Profile::~TAO_UIOP_Profile (void)
{
- assert (this->refcount_ == 0);
-
delete [] this->rendezvous_point_;
this->rendezvous_point_ = 0;
}
-// return codes:
-// -1 -> error
-// 0 -> can't understand this version
-// 1 -> success.
-int
-TAO_UIOP_Profile::parse (TAO_InputCDR& cdr,
- CORBA::Boolean &continue_decoding,
- CORBA::Environment &env)
-{
- CORBA::ULong encap_len = cdr.length ();
-
- if (TAO_debug_level > 0)
- {
- char *buf = (char *) cdr.rd_ptr (); // ptr to first buffer
- ACE_HEX_DUMP ((LM_DEBUG,
- (const char*)buf,
- encap_len,
- "\n"));
- }
-
- // Read and verify major, minor versions, ignoring UIOP
- // profiles whose versions we don't understand.
- // FIXME: Version question again, what do we do about them for this
- // protocol?
-
- if (!(cdr.read_octet (this->version_.major)
- && this->version_.major == TAO_UIOP_Profile::DEF_UIOP_MAJOR
- && cdr.read_octet (this->version_.minor)
- && this->version_.minor <= TAO_UIOP_Profile::DEF_UIOP_MINOR))
- {
- ACE_DEBUG ((LM_DEBUG,
- "detected new v%d.%d UIOP profile",
- this->version_.major,
- this->version_.minor));
- return 0;
- }
-
- if (this->rendezvous_point_)
- {
- delete [] this->rendezvous_point_;
- this->rendezvous_point_ = 0;
- }
-
- // Get rendezvous_point
- if (cdr.read_string (this->rendezvous_point_) == 0)
- {
- ACE_DEBUG ((LM_DEBUG, "error decoding UIOP rendezvous_point"));
- return -1;
- }
-
- this->object_addr_.set (this->rendezvous_point_);
-
- // ... and object key.
-
- if ((cdr >> this->object_key_) == 0)
- return -1;
-
- if (cdr.length () != 0 && TAO_debug_level)
- {
- // If there is extra data in the profile we are supposed to
- // ignore it, but print a warning just in case...
- ACE_DEBUG ((LM_DEBUG,
- "%d bytes out of %d left after UIOP profile data\n",
- cdr.length (),
- encap_len));
- }
-
-// ACE_DEBUG ((LM_DEBUG,
-// "UIOP_Profile --- r point: <%s>\n",
-// this->rendezvous_point_));
-
- if (cdr.good_bit ())
- return 1;
-
- return -1;
-}
-
int
TAO_UIOP_Profile::parse_string (const char *string,
CORBA::Environment &ACE_TRY_ENV)
@@ -578,41 +475,9 @@ TAO_UIOP_Profile::operator= (const TAO_UIOP_Profile &src)
return *this;
}
-// Memory managment
-
-CORBA::ULong
-TAO_UIOP_Profile::_incr_refcnt (void)
-{
- // OK, think I got it. When this object is created (guard) the
- // lock is automatically acquired (refcount_lock_). Then when
- // we leave this method the destructir for guard is called which
- // releases the lock!
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->refcount_lock_, 0);
-
- return this->refcount_++;
-}
-
-CORBA::ULong
-TAO_UIOP_Profile::_decr_refcnt (void)
-{
- {
- ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->refcount_lock_, 0);
- this->refcount_--;
- if (this->refcount_ != 0)
- return this->refcount_;
- }
-
- // refcount is 0, so delete us!
- // delete will call our ~ destructor which in turn deletes stuff.
- delete this;
- return 0;
-}
-
CORBA::String
-TAO_UIOP_Profile::to_string (CORBA::Environment &env)
+TAO_UIOP_Profile::to_string (CORBA::Environment &)
{
- ACE_UNUSED_ARG (env);
-
CORBA::String_var key;
TAO_POA::encode_sequence_to_string (key.inout(),
this->object_key ());
@@ -645,6 +510,81 @@ TAO_UIOP_Profile::prefix (void)
return ::prefix_;
}
+// return codes:
+// -1 -> error
+// 0 -> can't understand this version
+// 1 -> success.
+int
+TAO_UIOP_Profile::decode (TAO_InputCDR& cdr)
+{
+ CORBA::ULong encap_len = cdr.length ();
+
+ if (TAO_debug_level > 0)
+ {
+ char *buf = (char *) cdr.rd_ptr (); // ptr to first buffer
+ ACE_HEX_DUMP ((LM_DEBUG,
+ (const char*)buf,
+ encap_len,
+ "\n"));
+ }
+
+ // Read and verify major, minor versions, ignoring UIOP
+ // profiles whose versions we don't understand.
+ // FIXME: Version question again, what do we do about them for this
+ // protocol?
+
+ if (!(cdr.read_octet (this->version_.major)
+ && this->version_.major == TAO_UIOP_Profile::DEF_UIOP_MAJOR
+ && cdr.read_octet (this->version_.minor)
+ && this->version_.minor <= TAO_UIOP_Profile::DEF_UIOP_MINOR))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "detected new v%d.%d UIOP profile",
+ this->version_.major,
+ this->version_.minor));
+ return 0;
+ }
+
+ if (this->rendezvous_point_)
+ {
+ delete [] this->rendezvous_point_;
+ this->rendezvous_point_ = 0;
+ }
+
+ // Get rendezvous_point
+ if (cdr.read_string (this->rendezvous_point_) == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "error decoding UIOP rendezvous_point"));
+ return -1;
+ }
+
+ this->object_addr_.set (this->rendezvous_point_);
+
+ // ... and object key.
+
+ if ((cdr >> this->object_key_) == 0)
+ return -1;
+
+ if (cdr.length () != 0 && TAO_debug_level)
+ {
+ // If there is extra data in the profile we are supposed to
+ // ignore it, but print a warning just in case...
+ ACE_DEBUG ((LM_DEBUG,
+ "%d bytes out of %d left after UIOP profile data\n",
+ cdr.length (),
+ encap_len));
+ }
+
+// ACE_DEBUG ((LM_DEBUG,
+// "UIOP_Profile --- r point: <%s>\n",
+// this->rendezvous_point_));
+
+ if (cdr.good_bit ())
+ return 1;
+
+ return -1;
+}
+
int
TAO_UIOP_Profile::encode (TAO_OutputCDR &stream) const
{
diff --git a/TAO/tao/UIOP_Profile.h b/TAO/tao/UIOP_Profile.h
index 02e2ed89183..18e7ca4c14c 100644
--- a/TAO/tao/UIOP_Profile.h
+++ b/TAO/tao/UIOP_Profile.h
@@ -106,11 +106,6 @@ public:
~TAO_UIOP_Profile (void);
// Destructor is to be called only through <_decr_refcnt>.
- int parse (TAO_InputCDR& cdr,
- CORBA::Boolean& continue_decoding,
- CORBA::Environment &env);
- // Initialize this object using the given CDR octet string.
-
int parse_string (const char *string,
CORBA::Environment &env);
// Initialize this object using the given input string.
@@ -122,6 +117,9 @@ public:
const TAO_opaque& body (void) const;
// Create UIOP_Profile Object from marshalled data.
+ int decode (TAO_InputCDR& cdr);
+ // Initialize this object using the given CDR octet string.
+
virtual int encode (TAO_OutputCDR &stream) const;
// Encode this profile in a stream, i.e. marshal it.
// FIXME: NO MARSHALING for Unix Domain Sockets is needing
@@ -180,13 +178,6 @@ public:
TAO_UIOP_Profile & operator= (const TAO_UIOP_Profile &src);
// Assignment operator
- virtual CORBA::ULong _incr_refcnt (void);
- // Increase the reference count by one on this object.
-
- virtual CORBA::ULong _decr_refcnt (void);
- // Decrement the object's reference count. When this count goes to
- // 0 this object will be deleted.
-
private:
int set (const ACE_UNIX_Addr &addr);
// helper method to set the UNIX_Addr.
@@ -216,12 +207,6 @@ private:
// Pointer to a connection handler which we successfully used
// already.
- ACE_SYNCH_MUTEX refcount_lock_;
- // Mutex to protect reference count.
-
- CORBA::ULong refcount_;
- // Number of outstanding references to this object.
-
TAO_MProfile *forward_to_;
// list of profiles which we should try forwarding on.
};