diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-11-14 06:59:38 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-11-14 06:59:38 +0000 |
commit | 66089b79acd223d9c8477a7599841da548132d26 (patch) | |
tree | 26fd5bf49b0caea5d9ee1f962df75b03bad4ead7 /TAO | |
parent | 0e7895552e9d3918b7c8195083a948f13a7d19cb (diff) | |
download | ATCD-66089b79acd223d9c8477a7599841da548132d26.tar.gz |
*** empty log message ***
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog-98c | 16 | ||||
-rw-r--r-- | TAO/tao/decode.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/giop.cpp | 4 | ||||
-rw-r--r-- | TAO/tao/iiopobj.cpp | 203 | ||||
-rw-r--r-- | TAO/tao/iiopobj.h | 65 | ||||
-rw-r--r-- | TAO/tao/iiopobj.i | 8 | ||||
-rw-r--r-- | TAO/tao/iioporb.cpp | 12 | ||||
-rw-r--r-- | TAO/tao/poa.cpp | 14 |
8 files changed, 226 insertions, 99 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index e1f8a89672d..6fcf4e96713 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,8 @@ +Fri Nov 14 00:03:20 1997 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * tao/iiopobj.cpp (Profile): Modified the code to consistently + store a NUL at the end of each object key string. + Fri Nov 14 00:29:09 1997 David L. Levine <levine@cs.wustl.edu> * TAO_IDL/fe/lex.yy.cpp: set RCS -ko option so that the Id keyword @@ -6,6 +11,17 @@ Fri Nov 14 00:29:09 1997 David L. Levine <levine@cs.wustl.edu> Thu Nov 13 19:11:36 1997 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu> + * tao/giop.cpp (start): Updated the code to use the new + object_addr() style. + + * tao/iiopobj: Added many fixes to the Profile code to fix nasty + bugs. Also, renamed {get|set}_object_addr() to simply + object_addr(), which is the correct style. + + * tao/iiopobj.h: Replaced the use of "localhost" with + ACE_DEFAULT_SERVER_HOST. This is necessary to support broken + platforms like MVS that don't support "localhost"... + * TAO/tests/Cubit/TAO/IDL_Cubit/svr.cpp (parse_args): Assume for the moment that any arguments starting with `-O' are `-ORB' or `-OA'. This should be fixed by having the ORB_init() and diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp index 5593600f7e7..c37527db63a 100644 --- a/TAO/tao/decode.cpp +++ b/TAO/tao/decode.cpp @@ -611,7 +611,8 @@ TAO_Marshal_ObjRef::decode (CORBA::TypeCode_ptr, objdata->Release (); return CORBA::TypeCode::TRAVERSE_STOP; } - profile->set_object_addr (); + + profile->object_addr (); // ... and object key diff --git a/TAO/tao/giop.cpp b/TAO/tao/giop.cpp index 2009b813363..4d3f33ed2a9 100644 --- a/TAO/tao/giop.cpp +++ b/TAO/tao/giop.cpp @@ -638,12 +638,12 @@ TAO_GIOP_Invocation::start (CORBA::Environment &env) if (data_->fwd_profile_i () != 0) { key = &data_->fwd_profile_i ()->object_key; - server_addr_p = &data_->fwd_profile_i ()->get_object_addr (); + server_addr_p = &data_->fwd_profile_i ()->object_addr (); } else { key = &data_->profile.object_key; - server_addr_p = &data_->profile.get_object_addr (); + server_addr_p = &data_->profile.object_addr (); } } diff --git a/TAO/tao/iiopobj.cpp b/TAO/tao/iiopobj.cpp index 029940ccf5d..8596db5d697 100644 --- a/TAO/tao/iiopobj.cpp +++ b/TAO/tao/iiopobj.cpp @@ -10,52 +10,142 @@ #include "tao/corba.h" -IIOP::Profile::Profile (const IIOP::Profile &src) - : iiop_version (src.iiop_version), - port (src.port) +int +IIOP::Profile::set (const char *h, + const CORBA::UShort p, + const ACE_INET_Addr *addr) { - assert (src.iiop_version.major == MY_MAJOR); - assert (src.iiop_version.minor == MY_MINOR); + this->iiop_version.major = IIOP::MY_MAJOR; + this->iiop_version.minor = IIOP::MY_MINOR; - // Free up our host if we've got one. if (this->host) ACE_OS::free (this->host); - - this->host = ACE_OS::strdup (src.host); - this->object_key.length = src.object_key.length; - this->object_key.maximum = src.object_key.length; + this->port = p; + this->host = ACE_OS::strdup (h); + if (this->host == 0) + return -1; + this->object_addr (addr); + return 0; +} + +int +IIOP::Profile::set (const char *h, + const CORBA::UShort p, + const char *key, + const ACE_INET_Addr *addr) +{ + if (this->set (h, p, addr) == -1) + return -1; - // object_key.buffer = (CORBA::Octet *) ACE_OS::malloc (object_key.maximum); - this->object_key.buffer = new CORBA::Octet [this->object_key.maximum]; + this->object_key.length = ACE_OS::strlen (key); + this->object_key.maximum = this->object_key.length; - (void) ACE_OS::memcpy (this->object_key.buffer, - src.object_key.buffer, - this->object_key.length); - this->set_object_addr (); + ACE_NEW_RETURN (this->object_key.buffer, + CORBA::Octet[this->object_key.maximum + 1], + -1); + + (void) ACE_OS::strcpy ((char *) this->object_key.buffer, key); + return 0; } -IIOP::Profile::Profile (const IIOP::Version &v, - const char *h, - const CORBA::UShort p, - const TAO_opaque &key) - : iiop_version (v), - port (p) +int +IIOP::Profile::set (const char *h, + const CORBA::UShort p, + const TAO_opaque &key, + const ACE_INET_Addr *addr) { - this->host = ACE_OS::strdup (h); + if (this->set (h, p, addr) == -1) + return -1; + this->object_key.length = key.length; this->object_key.maximum = key.length; - // object_key.buffer = (CORBA::Octet *) ACE_OS::malloc (object_key.maximum); - this->object_key.buffer = new CORBA::Octet [object_key.maximum]; + ACE_NEW_RETURN (this->object_key.buffer, + CORBA::Octet[key.maximum + 1], + -1); - (void) ACE_OS::memcpy (this->object_key.buffer, + (void) ACE_OS::memcpy ((char *) this->object_key.buffer, key.buffer, - this->object_key.length); - this->set_object_addr (); + key.length); + // NUL-terminate this guy... + this->object_key.buffer[key.length] = '\0'; + return 0; +} + +IIOP::Profile::Profile (const IIOP::Profile &src) +{ + (void) this->set (src.host, + src.port, + src.object_key, + &src.object_addr_); +} + +int +IIOP::Profile::set (const ACE_INET_Addr &addr, + const char *key) +{ + // Set up an IIOP object to hold the host name. + char tempname[MAXHOSTNAMELEN + 1]; + + // Retrieve the host name. + if (addr.get_host_name (tempname, + MAXHOSTNAMELEN) == -1) + return -1; + else + return this->set (tempname, + addr.get_port_number (), + key, + &addr); +} + +int +IIOP::Profile::set (const ACE_INET_Addr &addr, + const TAO_opaque &key) +{ + // Set up an IIOP object to hold the host name. + char tempname[MAXHOSTNAMELEN + 1]; + + // Retrieve the host name. + if (addr.get_host_name (tempname, + MAXHOSTNAMELEN) == -1) + return -1; + else + return this->set (tempname, + addr.get_port_number (), + key, + &addr); +} + +IIOP::Profile::Profile (const char *h, + const CORBA::UShort p, + const char *key) +{ + (void) this->set (h, p, key); +} + +IIOP::Profile::Profile (const char *h, + const CORBA::UShort p, + const char *key, + const ACE_INET_Addr &addr) +{ + (void) this->set (h, p, key, &addr); +} + +IIOP::Profile::Profile (const ACE_INET_Addr &addr, + const char *key) +{ + (void) this->set (addr, key); +} + +IIOP::Profile::Profile (const ACE_INET_Addr &addr, + const TAO_opaque &key) +{ + (void) this->set (addr, key); } -// Quick'n'dirty hash of objref data, for partitioning objrefs into sets +// Quick'n'dirty hash of objref data, for partitioning objrefs into +// sets. // // NOTE that this must NOT go across the network! @@ -186,66 +276,41 @@ IIOP_Object::QueryInterface (REFIID riid, char * IIOP_Object::_get_name (CORBA::Environment &) { - char *name; - - name = CORBA::string_alloc (this->profile.object_key.length); - ACE_OS::memset (name, '\0', this->profile.object_key.length+1); - ACE_OS::memcpy (name, this->profile.object_key.buffer, + char *name = CORBA::string_alloc (this->profile.object_key.length); + ACE_OS::memcpy (name, + this->profile.object_key.buffer, this->profile.object_key.length); return name; } -// Constructor -// It will usually be used by the _bind call +// It will usually be used by the _bind call. +// +// Note that if the repository ID (typeID) is NULL, it will make +// narrowing rather expensive, though it does ensure that type-safe +// narrowing code gets thoroughly exercised/debugged! Without a +// typeID, the _narrow will be required to make an expensive remote +// "is_a" call. + IIOP_Object::IIOP_Object (const char *host, const CORBA::UShort port, const char *objkey, char *repository_id) : STUB_Object (repository_id), + profile (host, port, objkey), base (this), refcount_ (1), fwd_profile_ (0) { - // If the repository ID (typeID) is NULL, it will make narrowing - // rather expensive, though it does ensure that type-safe narrowing - // code gets thoroughly excercised/debugged! Without a typeID, the - // _narrow will be required to make an expensive remote "is_a" call. - - // we set this to use IIOP version 1.0 - this->profile.iiop_version.major = IIOP::MY_MAJOR; - this->profile.iiop_version.minor = IIOP::MY_MINOR; - - // set the profile information - this->profile.host = ACE_OS::strdup (host); - this->profile.port = port; - - // set the obj key in the profile info - this->profile.object_key.buffer = (u_char *) CORBA::string_copy (objkey); - this->profile.object_key.length = ACE_OS::strlen (objkey); - this->profile.object_key.maximum = this->profile.object_key.length; } // Constructor. It will usually be used by the server side. IIOP_Object::IIOP_Object (char *repository_id, - const ACE_INET_Addr &addr, const - char *objkey) + const ACE_INET_Addr &addr, + const char *objkey) : STUB_Object (repository_id), + profile (addr, objkey), base (this), refcount_ (1), fwd_profile_ (0) { - // set up an IIOP object - char tempname [MAXHOSTNAMELEN]; // to hold the host name - - // setup the profile information - this->profile.iiop_version.major = IIOP::MY_MAJOR; - this->profile.iiop_version.minor = IIOP::MY_MINOR; - ACE_OS::memset (tempname, '\0', MAXHOSTNAMELEN); - (void) addr.get_host_name (tempname, MAXHOSTNAMELEN); // retrieve the host - // name - this->profile.host = ACE_OS::strdup (tempname); - this->profile.port = addr.get_port_number (); - this->profile.object_key.length = ACE_OS::strlen (objkey); - this->profile.object_key.maximum = this->profile.object_key.length; - this->profile.object_key.buffer = (u_char *) CORBA::string_copy (objkey); } diff --git a/TAO/tao/iiopobj.h b/TAO/tao/iiopobj.h index 634bd613f37..7dc0b5659da 100644 --- a/TAO/tao/iiopobj.h +++ b/TAO/tao/iiopobj.h @@ -40,7 +40,8 @@ public: CORBA::Octet major; CORBA::Octet minor; - Version (CORBA::Octet maj = MY_MAJOR, CORBA::Octet min = MY_MINOR); + Version (CORBA::Octet maj = MY_MAJOR, + CORBA::Octet min = MY_MINOR); }; struct Profile @@ -57,23 +58,67 @@ public: CORBA::UShort port; Profile (void); + // Default constructor. Profile (const Profile &src); - Profile (const Version &v, - const char *h, - const CORBA::UShort p, + // Copy constructor. + + Profile (const char *host, + const CORBA::UShort port, + const char *object_key); + // Called by client <_bind>. + + Profile (const char *host, + const CORBA::UShort port, + const char *object_key, + const ACE_INET_Addr &addr); + // Called by server. + + Profile (const ACE_INET_Addr &addr, + const char *object_key); + // Called by client or server. + + Profile (const ACE_INET_Addr &addr, const TAO_opaque &object_key); + // Called by client or server. ~Profile (void); + // Destructor. - void set_object_addr (void); + void object_addr (const ACE_INET_Addr *); // Sets <object_addr_> cache from <host> and <port> - ACE_INET_Addr& get_object_addr (void); + ACE_INET_Addr &object_addr (void); // Returns the <ACE_INET_Addr> for this profile. private: + int set (const char *host, + const CORBA::UShort port, + const ACE_INET_Addr *addr); + // Internal helper method (called by the next two methods). + + int set (const char *host, + const CORBA::UShort port, + const char *object_key, + const ACE_INET_Addr *addr = 0); + // Called by server. + + int set (const char *host, + const CORBA::UShort port, + const TAO_opaque &object_key, + const ACE_INET_Addr *addr = 0); + // Called by server. + + int set (const ACE_INET_Addr &addr, + const char *object_key); + // Called by client or server. + + int set (const ACE_INET_Addr &addr, + const TAO_opaque &object_key); + // Called by client or server. + Profile &operator = (const Profile &src); + // Disallow copy constructor. ACE_INET_Addr object_addr_; // Cached instance of <ACE_INET_Addr> for use in making @@ -114,7 +159,7 @@ public: // = Support for tables keyed by objrefs. CORBA::ULong hash (CORBA::ULong maximum, - CORBA::Environment &env); + CORBA::Environment &env); CORBA::Boolean is_equivalent (CORBA::Object_ptr other_obj, CORBA::Environment &env); // XXX All objref representations should know how to marshal @@ -163,8 +208,8 @@ public: // client side. IIOP_Object (char *repository_id, - const ACE_INET_Addr &addr, const - char *objkey = "0"); + const ACE_INET_Addr &addr, + const char *objkey = "0"); // Constructor used typically by the server side. // = COM stuff @@ -177,9 +222,11 @@ public: // Get the underlying object key. IIOP::Profile profile; + // @@ Please document me (this should be private). private: CORBA::Object base; + // @@ Please document me. ACE_SYNCH_MUTEX IUnknown_lock_; // Mutex to protect <IUnknown>-related stuff. diff --git a/TAO/tao/iiopobj.i b/TAO/tao/iiopobj.i index e673aa16dec..643e6c5bae6 100644 --- a/TAO/tao/iiopobj.i +++ b/TAO/tao/iiopobj.i @@ -18,14 +18,16 @@ IIOP::Profile::~Profile (void) } ACE_INLINE void -IIOP::Profile::set_object_addr (void) +IIOP::Profile::object_addr (const ACE_INET_Addr *addr) { - if (this->host) + if (addr != 0) + this->object_addr_ = *addr; + else if (this->host) this->object_addr_.set (this->port, this->host); } ACE_INLINE ACE_INET_Addr & -IIOP::Profile::get_object_addr (void) +IIOP::Profile::object_addr (void) { return this->object_addr_; } diff --git a/TAO/tao/iioporb.cpp b/TAO/tao/iioporb.cpp index 6c8f29b4a91..585220bc577 100644 --- a/TAO/tao/iioporb.cpp +++ b/TAO/tao/iioporb.cpp @@ -257,7 +257,7 @@ iiop_string_to_object (CORBA::String string, *cp = 0; string++; - cp = ACE_OS::strchr ((char *)string, '/'); + cp = ACE_OS::strchr ((char *) string, '/'); if (cp == 0) { @@ -267,15 +267,16 @@ iiop_string_to_object (CORBA::String string, return 0; } - data->profile.port = (short) ACE_OS::atoi ((char *)string); - data->profile.set_object_addr (); + data->profile.port = (short) ACE_OS::atoi ((char *) string); + data->profile.object_addr (0); string = ++cp; // Parse the key ... it's ASCII plus hex escapes for everything // nonprintable. This assumes that printable ASCII is the common // case ... but since stringification is uncommon, no big deal. - data->profile.object_key.buffer = (u_char *) CORBA::string_copy (string); + data->profile.object_key.buffer = + (u_char *) CORBA::string_copy (string); // Strip out whitespace and adjust length accordingly. @@ -311,7 +312,8 @@ iiop_string_to_object (CORBA::String string, // Return the objref. CORBA::Object_ptr obj; - (void) data->QueryInterface (IID_CORBA_Object, (void **)&obj); + (void) data->QueryInterface (IID_CORBA_Object, + (void **) &obj); data->Release (); return obj; } diff --git a/TAO/tao/poa.cpp b/TAO/tao/poa.cpp index 7097e823cf1..6f98831c2bb 100644 --- a/TAO/tao/poa.cpp +++ b/TAO/tao/poa.cpp @@ -78,17 +78,11 @@ CORBA_POA::create (CORBA::OctetSeq &key, else id = 0; - IIOP::Version ver (IIOP::MY_MAJOR, IIOP::MY_MINOR); - const ACE_INET_Addr &addr = TAO_ORB_Core_instance ()->orb_params ()->addr (); - - char host[MAXHOSTNAMELEN + 1]; - if (addr.get_host_name (host, MAXHOSTNAMELEN) == -1) - return 0; - data = new IIOP_Object (id, IIOP::Profile (ver, - host, - addr.get_port_number (), - key)); + + data = new IIOP_Object (id, + IIOP::Profile (TAO_ORB_Core_instance ()->orb_params ()->addr (), + key)); if (data != 0) env.clear (); else |