#include <SHMIOP_Endpoint.h>
Inheritance diagram for TAO_SHMIOP_Endpoint:
Public Member Functions | |
TAO_SHMIOP_Endpoint (void) | |
Default constructor. | |
TAO_SHMIOP_Endpoint (const char *host, CORBA::UShort port, const ACE_INET_Addr &addr, CORBA::Short priority=TAO_INVALID_PRIORITY) | |
TAO_SHMIOP_Endpoint (const ACE_MEM_Addr &addr, int use_dotted_decimal_addresses) | |
Constructor. | |
TAO_SHMIOP_Endpoint (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) | |
TAO_SHMIOP_Endpoint (const char *host, CORBA::UShort port, CORBA::Short priority) | |
Constructor. This constructor is used when decoding endpoints. | |
~TAO_SHMIOP_Endpoint (void) | |
Destructor. | |
const ACE_INET_Addr & | object_addr (void) const |
Return a reference to the <object_addr>. | |
const char * | host (void) const |
const char * | host (const char *h) |
CORBA::UShort | port (void) const |
Return the port number. | |
CORBA::UShort | port (CORBA::UShort p) |
Set the port number. | |
TAO_Endpoint Methods | |
virtual TAO_Endpoint * | next (void) |
Return a copy of this . | |
virtual int | addr_to_string (char *buffer, size_t length) |
Return a copy of this . | |
virtual TAO_Endpoint * | duplicate (void) |
Return a copy of this . | |
CORBA::Boolean | is_equivalent (const TAO_Endpoint *other_endpoint) |
CORBA::ULong | hash (void) |
Return a hash value for this object. | |
Private Member Functions | |
int | set (const ACE_INET_Addr &addr, int use_dotted_decimal_addresses) |
Helper method for setting INET_Addr. | |
Private Attributes | |
CORBA::String_var | host_ |
String representing the host name. | |
CORBA::UShort | port_ |
TCP port number. | |
ACE_INET_Addr | object_addr_ |
int | object_addr_set_ |
Flag to indicate if the address has been resolved and set. | |
TAO_SHMIOP_Endpoint * | next_ |
Friends | |
class | TAO_SHMIOP_Profile |
SHMIOP-specific implementation of PP Framework Endpoint interface.
Definition at line 43 of file SHMIOP_Endpoint.h.
TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint | ( | void | ) |
Default constructor.
Definition at line 66 of file SHMIOP_Endpoint.cpp.
00067 : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE) 00068 , host_ () 00069 , port_ (0) 00070 , object_addr_ () 00071 , object_addr_set_ (0) 00072 , next_ (0) 00073 { 00074 }
TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint | ( | const char * | host, | |
CORBA::UShort | port, | |||
const ACE_INET_Addr & | addr, | |||
CORBA::Short | priority = TAO_INVALID_PRIORITY | |||
) |
Constructor. This is the most efficient constructor since it does not require any address resolution processing.
Definition at line 51 of file SHMIOP_Endpoint.cpp.
References host_.
00055 : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE, priority) 00056 , host_ () 00057 , port_ (port) 00058 , object_addr_ (addr) 00059 , object_addr_set_ (0) 00060 , next_ (0) 00061 { 00062 if (host != 0) 00063 this->host_ = host; 00064 }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint | ( | const ACE_MEM_Addr & | addr, | |
int | use_dotted_decimal_addresses | |||
) |
Constructor.
Definition at line 27 of file SHMIOP_Endpoint.cpp.
References set().
00029 : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE) 00030 , host_ () 00031 , port_ (0) 00032 , object_addr_ (addr.get_remote_addr ()) 00033 , object_addr_set_ (0) 00034 , next_ (0) 00035 { 00036 this->set (addr.get_remote_addr (), use_dotted_decimal_addresses); 00037 }
TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint | ( | const ACE_INET_Addr & | addr, | |
int | use_dotted_decimal_addresses | |||
) |
Constructor. -- More of a extension of the previous one. One of them need to go. We will decide about that as time goes by.
Definition at line 39 of file SHMIOP_Endpoint.cpp.
References set().
00041 : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE) 00042 , host_ () 00043 , port_ (0) 00044 , object_addr_ (addr) 00045 , object_addr_set_ (0) 00046 , next_ (0) 00047 { 00048 this->set (addr, use_dotted_decimal_addresses); 00049 }
TAO_SHMIOP_Endpoint::TAO_SHMIOP_Endpoint | ( | const char * | host, | |
CORBA::UShort | port, | |||
CORBA::Short | priority | |||
) |
Constructor. This constructor is used when decoding endpoints.
Definition at line 76 of file SHMIOP_Endpoint.cpp.
References host_, and TAO_Endpoint::priority().
00079 : TAO_Endpoint (TAO_TAG_SHMEM_PROFILE) 00080 , host_ () 00081 , port_ (port) 00082 , object_addr_ () 00083 , object_addr_set_ (0) 00084 , next_ (0) 00085 { 00086 if (host != 0) 00087 this->host_ = host; 00088 00089 this->priority (priority); 00090 }
TAO_SHMIOP_Endpoint::~TAO_SHMIOP_Endpoint | ( | void | ) |
int TAO_SHMIOP_Endpoint::addr_to_string | ( | char * | buffer, | |
size_t | length | |||
) | [virtual] |
Return a copy of this
.
Implements TAO_Endpoint.
Definition at line 135 of file SHMIOP_Endpoint.cpp.
References port_, ACE_OS::sprintf(), and ACE_OS::strlen().
00136 { 00137 size_t actual_len = 00138 ACE_OS::strlen (this->host_.in ()) // chars in host name 00139 + sizeof (':') // delimiter 00140 + ACE_OS::strlen ("65536") // max port 00141 + sizeof ('\0'); 00142 00143 if (length < actual_len) 00144 return -1; 00145 00146 ACE_OS::sprintf (buffer, "%s:%d", 00147 this->host_.in (), this->port_); 00148 00149 return 0; 00150 }
TAO_Endpoint * TAO_SHMIOP_Endpoint::duplicate | ( | void | ) | [virtual] |
Return a copy of this
.
Implements TAO_Endpoint.
Definition at line 167 of file SHMIOP_Endpoint.cpp.
References ACE_NEW_RETURN, object_addr_, port_, and TAO_Endpoint::priority().
00168 { 00169 TAO_SHMIOP_Endpoint *endpoint = 0; 00170 ACE_NEW_RETURN (endpoint, 00171 TAO_SHMIOP_Endpoint (this->host_.in (), 00172 this->port_, 00173 this->object_addr_, 00174 this->priority ()), 00175 0); 00176 00177 return endpoint; 00178 }
CORBA::ULong TAO_SHMIOP_Endpoint::hash | ( | void | ) | [virtual] |
Return a hash value for this object.
Implements TAO_Endpoint.
Definition at line 196 of file SHMIOP_Endpoint.cpp.
References ACE_GUARD_RETURN, ACE::hash_pjw(), TAO_Endpoint::hash_val_, and TAO_SYNCH_MUTEX.
00197 { 00198 if (this->hash_val_ != 0) 00199 return this->hash_val_; 00200 00201 { 00202 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00203 guard, 00204 this->addr_lookup_lock_, 00205 this->hash_val_); 00206 // .. DCL 00207 if (this->hash_val_ != 0) 00208 return this->hash_val_; 00209 00210 this->hash_val_ = 00211 ACE::hash_pjw (this->host ()) + this->port (); 00212 } 00213 00214 return this->hash_val_; 00215 }
const char * TAO_SHMIOP_Endpoint::host | ( | const char * | h | ) |
Copy the string <h> into <host_> and return the resulting pointer. This object maintains ownership of this string.
Definition at line 153 of file SHMIOP_Endpoint.cpp.
References host_.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE const char * TAO_SHMIOP_Endpoint::host | ( | void | ) | const |
Return a pointer to the host string. This object maintains ownership of this string.
Definition at line 8 of file SHMIOP_Endpoint.inl.
References host_.
Referenced by TAO_SHMIOP_Connector::make_connection().
00009 { 00010 return this->host_.in (); 00011 }
CORBA::Boolean TAO_SHMIOP_Endpoint::is_equivalent | ( | const TAO_Endpoint * | other_endpoint | ) | [virtual] |
Return true if this endpoint is equivalent to other_endpoint. Two endpoints are equivalent iff their port and host are the same.
Implements TAO_Endpoint.
Definition at line 182 of file SHMIOP_Endpoint.cpp.
References host_, port_, and ACE_OS::strcmp().
00183 { 00184 const TAO_SHMIOP_Endpoint *endpoint = dynamic_cast <const TAO_SHMIOP_Endpoint *> 00185 (other_endpoint); 00186 00187 if (endpoint == 0) 00188 return 0; 00189 00190 return 00191 this->port_ == endpoint->port_ 00192 && ACE_OS::strcmp (this->host_.in (), endpoint->host_.in ()) == 0; 00193 }
TAO_Endpoint * TAO_SHMIOP_Endpoint::next | ( | void | ) | [virtual] |
Return a copy of this
.
Implements TAO_Endpoint.
Definition at line 161 of file SHMIOP_Endpoint.cpp.
References next_.
00162 { 00163 return this->next_; 00164 }
const ACE_INET_Addr & TAO_SHMIOP_Endpoint::object_addr | ( | void | ) | const |
Return a reference to the <object_addr>.
Definition at line 218 of file SHMIOP_Endpoint.cpp.
References ACE_GUARD_RETURN, TAO_Endpoint::addr_lookup_lock_, object_addr_, object_addr_set_, ACE_INET_Addr::set(), ACE_Addr::set_type(), and TAO_SYNCH_MUTEX.
Referenced by TAO_SHMIOP_Acceptor::is_collocated(), TAO_SHMIOP_Connector::make_connection(), and TAO_SHMIOP_Connector::set_validate_endpoint().
00219 { 00220 // The object_addr_ is initialized here, rather than at IOR decode 00221 // time for several reasons: 00222 // 1. A request on the object may never be invoked. 00223 // 2. The DNS setup may have changed dynamically. 00224 // ...etc.. 00225 00226 // Double checked locking optimization. 00227 if (!this->object_addr_set_) 00228 { 00229 // We need to modify the object_addr_ in this method. Do so 00230 // using a non-const copy of the <this> pointer. 00231 TAO_SHMIOP_Endpoint *endpoint = 00232 const_cast <TAO_SHMIOP_Endpoint *>(this); 00233 00234 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00235 guard, 00236 endpoint->addr_lookup_lock_, 00237 this->object_addr_ ); 00238 00239 if (!this->object_addr_set_) 00240 { 00241 if (endpoint->object_addr_.set (this->port_, 00242 this->host_.in ()) == -1) 00243 { 00244 // If this call fails, it most likely due a hostname 00245 // lookup failure caused by a DNS misconfiguration. If 00246 // a request is made to the object at the given host and 00247 // port, then a CORBA::TRANSIENT() exception should be 00248 // thrown. 00249 00250 // Invalidate the ACE_INET_Addr. This is used as a flag 00251 // to denote that ACE_INET_Addr initialization failed. 00252 endpoint->object_addr_.set_type (-1); 00253 } 00254 else 00255 { 00256 endpoint->object_addr_set_ = 1; 00257 } 00258 } 00259 } 00260 00261 return this->object_addr_; 00262 }
ACE_INLINE CORBA::UShort TAO_SHMIOP_Endpoint::port | ( | CORBA::UShort | p | ) |
Set the port number.
Definition at line 20 of file SHMIOP_Endpoint.inl.
References port_.
00021 { 00022 return this->port_ = p; 00023 }
ACE_INLINE CORBA::UShort TAO_SHMIOP_Endpoint::port | ( | void | ) | const |
Return the port number.
Definition at line 14 of file SHMIOP_Endpoint.inl.
References port_.
Referenced by TAO_SHMIOP_Connector::make_connection(), and TAO_SHMIOP_Profile::to_string().
00015 { 00016 return this->port_; 00017 }
int TAO_SHMIOP_Endpoint::set | ( | const ACE_INET_Addr & | addr, | |
int | use_dotted_decimal_addresses | |||
) | [private] |
Helper method for setting INET_Addr.
Definition at line 97 of file SHMIOP_Endpoint.cpp.
References ACE_DEBUG, ACE_TEXT, ACE_INET_Addr::get_host_addr(), ACE_INET_Addr::get_host_name(), ACE_INET_Addr::get_port_number(), host_, LM_DEBUG, MAXHOSTNAMELEN, port_, CORBA::string_dup(), and TAO_debug_level.
Referenced by TAO_SHMIOP_Endpoint().
00099 { 00100 char tmp_host[MAXHOSTNAMELEN + 1]; 00101 00102 if (use_dotted_decimal_addresses 00103 || addr.get_host_name (tmp_host, sizeof (tmp_host)) != 0) 00104 { 00105 if (use_dotted_decimal_addresses == 0 && TAO_debug_level > 5) 00106 { 00107 ACE_DEBUG ((LM_DEBUG, 00108 ACE_TEXT ("TAO (%P|%t) - SHMIOP_Endpoint::set, ") 00109 ACE_TEXT ("- %p cannot determine hostname\n"))); 00110 } 00111 00112 const char *tmp = addr.get_host_addr (); 00113 if (tmp == 0) 00114 { 00115 if (TAO_debug_level > 0) 00116 ACE_DEBUG ((LM_DEBUG, 00117 ACE_TEXT ("TAO (%P|%t) - ") 00118 ACE_TEXT ("SHMIOP_Endpoint::set ") 00119 ACE_TEXT ("- %p\n"), 00120 ACE_TEXT ("cannot determine hostname"))); 00121 return -1; 00122 } 00123 else 00124 this->host_ = tmp; 00125 } 00126 else 00127 this->host_ = CORBA::string_dup (tmp_host); 00128 00129 this->port_ = addr.get_port_number(); 00130 00131 return 0; 00132 }
friend class TAO_SHMIOP_Profile [friend] |
Definition at line 47 of file SHMIOP_Endpoint.h.
CORBA::String_var TAO_SHMIOP_Endpoint::host_ [private] |
String representing the host name.
Definition at line 122 of file SHMIOP_Endpoint.h.
Referenced by host(), is_equivalent(), TAO_SHMIOP_Profile::parse_string_i(), set(), and TAO_SHMIOP_Endpoint().
TAO_SHMIOP_Endpoint* TAO_SHMIOP_Endpoint::next_ [private] |
SHMIOP Endpoints can be stringed into a list. Return the next endpoint in the list, if any.
Definition at line 136 of file SHMIOP_Endpoint.h.
Referenced by TAO_SHMIOP_Profile::add_endpoint(), TAO_SHMIOP_Profile::do_is_equivalent(), and next().
Cached instance of <ACE_INET_Addr> for use in making invocations, etc.
Definition at line 129 of file SHMIOP_Endpoint.h.
Referenced by duplicate(), and object_addr().
int TAO_SHMIOP_Endpoint::object_addr_set_ [private] |
Flag to indicate if the address has been resolved and set.
Definition at line 132 of file SHMIOP_Endpoint.h.
Referenced by object_addr().
CORBA::UShort TAO_SHMIOP_Endpoint::port_ [private] |
TCP port number.
Definition at line 125 of file SHMIOP_Endpoint.h.
Referenced by addr_to_string(), duplicate(), is_equivalent(), TAO_SHMIOP_Profile::parse_string_i(), port(), and set().