From dc03b387ed2f4f8dbeccf35d14f6f3584c7cc75d Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Thu, 2 Mar 2000 01:30:59 +0000 Subject: ChangeLogTag:Wed Mar 1 17:27:45 2000 Ossama Othman --- TAO/tao/IIOP_Acceptor.cpp | 145 +++++++++++++++++++++++++--------------------- TAO/tao/IIOP_Acceptor.h | 9 ++- TAO/tao/ORB_Core.cpp | 2 +- TAO/tao/Stub.h | 2 +- 4 files changed, 89 insertions(+), 69 deletions(-) (limited to 'TAO') diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp index 8bffcab686b..3f30c643955 100644 --- a/TAO/tao/IIOP_Acceptor.cpp +++ b/TAO/tao/IIOP_Acceptor.cpp @@ -214,36 +214,15 @@ TAO_IIOP_Acceptor::open (TAO_ORB_Core *orb_core, ACE_CString[this->num_hosts_], -1); - if (orb_core->orb_params ()->use_dotted_decimal_addresses ()) - { - const char *tmp = addr.get_host_addr (); - if (tmp == 0) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("\n\nTAO (%P|%t) ") - ASYS_TEXT ("IIOP_Acceptor::open - %p\n\n"), - ASYS_TEXT ("cannot cache hostname"))); - return -1; - } - - this->hosts_[0] = tmp; - } - else - { - char tmp_host[MAXHOSTNAMELEN + 1]; - if (addr.get_host_name (tmp_host, - sizeof (tmp_host)) != 0) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("\n\nTAO (%P|%t) ") - ASYS_TEXT ("IIOP_Acceptor::open - %p\n\n"), - ASYS_TEXT ("cannot cache hostname"))); - return -1; - } - this->hosts_[0] = tmp_host; - } + if (this->hostname (orb_core, + addr, + this->hosts_[0]) != 0) + return -1; + + // Copy the addr. The port is (re)set in + // TAO_IIOP_Acceptor::open_i(). + if (this->addrs_[0].set (addr) != 0) + return -1; return this->open_i (orb_core, addr); } @@ -278,9 +257,25 @@ TAO_IIOP_Acceptor::open_default (TAO_ORB_Core *orb_core, if_addrs) != 0) return -1; + if (if_cnt == 0 || if_addrs == 0) + { + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_WARNING, + ASYS_TEXT ("TAO (%P|%t) Unable to probe network ") + ASYS_TEXT ("interfaces. Using default."))); + } + + if_cnt = 1; // Force the network interface count to be one. + delete [] if_addrs; + ACE_NEW_RETURN (if_addrs, + ACE_INET_Addr[if_cnt], + -1); + } + // Scan for the loopback interface since it shouldn't be included in // the list of cached hostnames unless it is the only interface. - size_t lo_cnt = 0; + size_t lo_cnt = 0; // Loopback interface count for (size_t j = 0; j < if_cnt; ++j) if (if_addrs[j].get_ip_address() == INADDR_LOOPBACK) lo_cnt++; @@ -327,39 +322,16 @@ TAO_IIOP_Acceptor::open_default (TAO_ORB_Core *orb_core, if_addrs[i].get_ip_address() == INADDR_LOOPBACK) continue; - if (orb_core->orb_params ()->use_dotted_decimal_addresses ()) - { - const char *tmp = if_addrs[i].get_host_addr (); - if (tmp == 0) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("\n\nTAO (%P|%t) ") - ASYS_TEXT ("IIOP_Acceptor::open_default ") - ASYS_TEXT ("- %p\n\n"), - ASYS_TEXT ("cannot cache hostname"))); - return -1; - } - this->hosts_[host_cnt] = tmp; - } - else - { - char tmp_host[MAXHOSTNAMELEN + 1]; - if (if_addrs[i].get_host_name (tmp_host, - sizeof (tmp_host)) != 0) - { - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("\n\nTAO (%P|%t) ") - ASYS_TEXT ("IIOP_Acceptor::open_default ") - ASYS_TEXT ("- %p\n\n"), - ASYS_TEXT ("cannot cache hostname"))); - return -1; - } - this->hosts_[host_cnt] = tmp_host; - } - - this->addrs_[host_cnt] = if_addrs[i]; // Copy the addr. + if (this->hostname (orb_core, + if_addrs[i], + this->hosts_[host_cnt]) != 0) + return -1; + + // Copy the addr. The port is (re)set in + // TAO_IIOP_Acceptor::open_i(). + if (this->addrs_[host_cnt].set (if_addrs[i]) != 0) + return -1; + host_cnt++; } } // End ACE_Auto_Basic_Array_Ptr scope. @@ -404,7 +376,8 @@ TAO_IIOP_Acceptor::open_i (TAO_ORB_Core* orb_core, { if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("\n\nTAO (%P|%t) IIOP_Acceptor::open_i - %p\n\n"), + ASYS_TEXT ("\n\nTAO (%P|%t) IIOP_Acceptor::open_i ") + ASYS_TEXT ("- %p\n\n"), ASYS_TEXT ("cannot open acceptor"))); return -1; } @@ -447,6 +420,48 @@ TAO_IIOP_Acceptor::open_i (TAO_ORB_Core* orb_core, return 0; } +int +TAO_IIOP_Acceptor::hostname (TAO_ORB_Core *orb_core, + ACE_INET_Addr &addr, + ACE_CString &host) +{ + if (orb_core->orb_params ()->use_dotted_decimal_addresses ()) + { + const char *tmp = addr.get_host_addr (); + if (tmp == 0) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("\n\nTAO (%P|%t) ") + ASYS_TEXT ("IIOP_Acceptor::hostname ") + ASYS_TEXT ("- %p\n\n"), + ASYS_TEXT ("cannot cache hostname"))); + return -1; + } + + host = tmp; + } + else + { + char tmp_host[MAXHOSTNAMELEN + 1]; + if (addr.get_host_name (tmp_host, + sizeof (tmp_host)) != 0) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("\n\nTAO (%P|%t) ") + ASYS_TEXT ("IIOP_Acceptor::hostname ") + ASYS_TEXT ("- %p\n\n"), + ASYS_TEXT ("cannot cache hostname"))); + return -1; + } + + host = tmp_host; + } + + return 0; +} + CORBA::ULong TAO_IIOP_Acceptor::endpoint_count (void) { diff --git a/TAO/tao/IIOP_Acceptor.h b/TAO/tao/IIOP_Acceptor.h index 6e9d8ddc1ff..c4ab088ef56 100644 --- a/TAO/tao/IIOP_Acceptor.h +++ b/TAO/tao/IIOP_Acceptor.h @@ -74,10 +74,15 @@ public: virtual CORBA::ULong endpoint_count (void); private: - int open_i (TAO_ORB_Core* orb_core, - const ACE_INET_Addr& addr); + int open_i (TAO_ORB_Core *orb_core, + const ACE_INET_Addr &addr); // Implement the common part of the open*() methods. + int hostname (TAO_ORB_Core *orb_core, + ACE_INET_Addr &addr, + ACE_CString &host); + // Set the host name for the given addr. + virtual int parse_options (const char *options); // Parse protocol specific options. diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index aa3945dad17..b407cfa3ca9 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -62,7 +62,7 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid) root_poa_ (0), root_poa_reference_ (), orb_params_ (), - orbid_ (ACE_OS::strdup (orbid?orbid:"")), + orbid_ (ACE_OS::strdup (orbid ? orbid : "")), resource_factory_ (0), resource_factory_from_service_config_ (0), // @@ This is not needed since the default resource factory, fredk diff --git a/TAO/tao/Stub.h b/TAO/tao/Stub.h index bf1c3f34bd7..a6f55df3aca 100644 --- a/TAO/tao/Stub.h +++ b/TAO/tao/Stub.h @@ -474,7 +474,7 @@ private: // ordered list of profiles for this object. TAO_MProfile *forward_profiles_; - // The list of forwarding profiles. This is actually iimplemented as a + // The list of forwarding profiles. This is actually implemented as a // linked list of TAO_MProfile objects. TAO_Profile *profile_in_use_; -- cgit v1.2.1