From fb9f22c31f495538e99c2af986cbf4ca69400e07 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 6 Mar 2015 09:03:51 -0600 Subject: Fixed fuzz error from pull request #23 --- ACE/ace/Dev_Poll_Reactor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/ace/Dev_Poll_Reactor.cpp b/ACE/ace/Dev_Poll_Reactor.cpp index c8ca2f96e3a..87d78be7197 100644 --- a/ACE/ace/Dev_Poll_Reactor.cpp +++ b/ACE/ace/Dev_Poll_Reactor.cpp @@ -1335,7 +1335,7 @@ ACE_Dev_Poll_Reactor::dispatch_io_event (Token_Guard &guard) } } #endif /* ACE_HAS_EVENT_POLL */ - } + } } } // Scope close handles eh ref count decrement, if needed. -- cgit v1.2.1 From b3e829bc1e2d4d37de89d83408a1c487b3892ba2 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 6 Mar 2015 09:28:12 -0600 Subject: Run the fuzz.pl script on Travis CI. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a590f9abae0..ee7002a9e70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ env: - CCMLW=1 ACEFORTAO=0 - CCMNOEVENT=1 ACEFORTAO=0 - ACETESTS=1 ACEFORTAO=0 + - FUZZ=1 global: - ACE_ROOT=$TRAVIS_BUILD_DIR/ACE - TAO_ROOT=$TRAVIS_BUILD_DIR/TAO @@ -50,6 +51,7 @@ before_script: - cat $ACE_ROOT/include/makeinclude/platform_macros.GNU script: + - if [ "$FUZZ" == "1" ]; then exec perl $ACE_ROOT/bin/fuzz.pl; fi - perl $ACE_ROOT/bin/mwc.pl -type gnuace -workers 2 travis.mwc - make -j 2 - perl $ACE_ROOT/bin/auto_run_tests.pl -l $TAO_ROOT/bin/travis-ci.lst -- cgit v1.2.1 From a9859274acb54b1193660d49d86749d71b820401 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 6 Mar 2015 09:39:29 -0600 Subject: Run fuzz script first on Travis CI. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee7002a9e70..eae990d0ca5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ compiler: - gcc env: matrix: + - FUZZ=1 - CORBAEMICRO=1 ACEFORTAO=0 - CORBAECOMPACT=1 ACEFORTAO=0 - ACEFORTAO=1 @@ -10,7 +11,6 @@ env: - CCMLW=1 ACEFORTAO=0 - CCMNOEVENT=1 ACEFORTAO=0 - ACETESTS=1 ACEFORTAO=0 - - FUZZ=1 global: - ACE_ROOT=$TRAVIS_BUILD_DIR/ACE - TAO_ROOT=$TRAVIS_BUILD_DIR/TAO -- cgit v1.2.1 From 7805370999f233118c5b3a7242b580d2d8214a0f Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Fri, 6 Mar 2015 16:09:47 -0500 Subject: Add ability for ACE_INET_Addr to hold all the addresses assigned to a name and allow ACE_Multihomed_INET_Addr to access them all. --- ACE/NEWS | 10 +++ ACE/ace/INET_Addr.cpp | 156 ++++++++++++++++++++++++++------------- ACE/ace/INET_Addr.h | 26 +++++-- ACE/ace/INET_Addr.inl | 2 +- ACE/ace/Multihomed_INET_Addr.cpp | 81 ++++++++++++++------ ACE/tests/INET_Addr_Test.cpp | 51 ++++++++++++- 6 files changed, 247 insertions(+), 79 deletions(-) diff --git a/ACE/NEWS b/ACE/NEWS index ead8d8db44f..2e2cb9b4628 100644 --- a/ACE/NEWS +++ b/ACE/NEWS @@ -8,6 +8,16 @@ USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 supported. Please see tests/Chrono_Test.cpp for more details. +. Allow ACE_INET_Addr to hold all addresses associated with a hostname. The + set of addresses always has a "current" address which is accessed by the + usual "get"-type methods on the class. Two new methods are added to deal + with multiple addresses: + - bool next (void): makes the next available address the "current" one. + Returns false if there are no more addresses. + - void reset (void): resets the iteration mechanism to be able to examine + all of the addresses again. + ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() + methods copy all available addresses related to each name. USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 1c422fdb899..2367fb2499d 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -152,11 +152,31 @@ ACE_INET_Addr::hash (void) const return this->get_ip_address () + this->get_port_number (); } +bool +ACE_INET_Addr::next (void) +{ + if (this->inet_addrs_.empty () || + this->inet_addrs_iter_ == this->inet_addrs_.end ()) + return false; + + union ip46 next_a = *this->inet_addrs_iter_++; + this->set_addr (&next_a, sizeof (next_a)); + return true; +} + +void +ACE_INET_Addr::reset (void) +{ + this->inet_addrs_iter_ = this->inet_addrs_.begin (); + this->next (); + return; +} + ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); } int @@ -176,6 +196,8 @@ ACE_INET_Addr::set (const ACE_INET_Addr &sa) this->set_type (sa.get_type()); this->set_size (sa.get_size()); + this->inet_addrs_ = sa.inet_addrs_; + this->reset (); } return 0; @@ -266,7 +288,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (address, address_family); } @@ -275,7 +297,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (address, address_family); } @@ -287,7 +309,7 @@ ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) : ACE_Addr (sa.get_type (), sa.get_size()) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (sa); } @@ -354,15 +376,22 @@ ACE_INET_Addr::set (u_short port_number, { if (hp != 0) { - struct sockaddr_in6 v6; - ACE_OS::memset (&v6, 0, sizeof (v6)); - v6.sin6_family = AF_INET6; - (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, - hp->h_addr, - hp->h_length); this->set_type (hp->h_addrtype); - this->set_addr (&v6, hp->h_length); - this->set_port_number (port_number, encode); + for (size_t i = 0; hp->h_addr_list[i]; ++i) + { + union ip46 next_addr; + struct sockaddr_in6 *next_addr_in6 = (struct sockaddr_in6 *)&next_addr.in6_; + (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); + next_addr_in6->sin6_family = AF_INET6; + next_addr_in6->sin6_port = + encode ? ACE_NTOHS (port_number) : port_number; + (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr, + hp->h_addr_list[i], + hp->h_length); + this->inet_addrs_.push_back (next_addr); + } + this->reset (); + return 0; } } @@ -371,16 +400,35 @@ ACE_INET_Addr::set (u_short port_number, return -1; # else struct addrinfo hints; - struct addrinfo *res = 0; + struct addrinfo *res = 0, *curr = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); - this->set_addr (res->ai_addr, - ACE_Utils::truncate_cast(res->ai_addrlen)); - this->set_port_number (port_number, encode); + for (curr = res; curr; curr = curr->ai_next) + { + union ip46 next_addr; + if (curr->ai_family == AF_INET6) + { + ACE_OS::memcpy (&next_addr.in6_, + curr->ai_addr, + curr->ai_addrlen); + next_addr.in6_.sin6_port = + encode ? ACE_NTOHS (port_number) : port_number; + } + else + { + ACE_OS::memcpy (&next_addr.in4_, + curr->ai_addr, + curr->ai_addrlen); + next_addr.in4_.sin_port = + encode ? ACE_NTOHS (port_number) : port_number; + } + this->inet_addrs_.push_back (next_addr); + } + this->reset (); ::freeaddrinfo (res); return 0; } @@ -406,34 +454,40 @@ ACE_INET_Addr::set (u_short port_number, struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - else { - hostent hentry; - ACE_HOSTENT_DATA buf; - int h_error = 0; // Not the same as errno! + this->inet_addrs_iter_ = this->inet_addrs_.end (); + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + } - hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, - buf, &h_error); - if (hp == 0) - errno = h_error; + hostent hentry; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! - if (hp == 0) - { - return -1; - } - else - { - (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, - hp->h_addr, - hp->h_length); - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - } + hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, + buf, &h_error); + if (hp == 0) + { + errno = h_error; + return -1; } + + this->set_type (hp->h_addrtype); + for (size_t i = 0; hp->h_addr_list[i]; ++i) + { + union ip46 next_addr; + struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_; + (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); + next_addr_in->sin_family = AF_INET; + next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number; + (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr, + hp->h_addr_list[i], + hp->h_length); + this->inet_addrs_.push_back (next_addr); + } + this->reset (); + return 0; } // Helper function to get a port number from a port name. @@ -609,17 +663,18 @@ ACE_INET_Addr::get_addr (void) const } void -ACE_INET_Addr::set_addr (void *addr, int len) +ACE_INET_Addr::set_addr (const void *addr, int len) { this->set_addr (addr, len, 0); } // Set a pointer to the address. void -ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) +ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) { ACE_TRACE ("ACE_INET_Addr::set_addr"); - struct sockaddr_in *getfamily = static_cast (addr); + const struct sockaddr_in *getfamily = + static_cast (addr); if (getfamily->sin_family == AF_INET) { @@ -637,7 +692,8 @@ ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) #if defined (ACE_HAS_IPV6) else if (getfamily->sin_family == AF_INET6) { - struct sockaddr_in6 *in6 = static_cast (addr); + const struct sockaddr_in6 *in6 = + static_cast (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast (&in6->sin6_addr), sizeof (in6->sin6_addr), @@ -653,7 +709,7 @@ ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (addr, len); } @@ -664,7 +720,7 @@ ACE_INET_Addr::ACE_INET_Addr (u_short port_number, : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -680,7 +736,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, host_name, protocol) == -1) @@ -695,7 +751,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, host_name, protocol) == -1) @@ -712,7 +768,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -727,7 +783,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h index 0c21df7b75b..357eac3f0d2 100644 --- a/ACE/ace/INET_Addr.h +++ b/ACE/ace/INET_Addr.h @@ -19,6 +19,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" +#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -27,6 +28,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Defines a C++ wrapper facade for the Internet domain address * family format. + * + * ACE_INET_Addr can hold all of the IP addresses assigned to a single name. + * By default it refers only to the first, if there is more than one. The + * next() method can make the others available in turn. */ class ACE_Export ACE_INET_Addr : public ACE_Addr { @@ -189,14 +194,14 @@ public: int get_addr_size(void) const; /// Set a pointer to the address. - virtual void set_addr (void *, int len); + virtual void set_addr (const void *, int len); /// Set a pointer to the address. - virtual void set_addr (void *, int len, int map); + virtual void set_addr (const void *, int len, int map); /** * Transform the current ACE_INET_Addr address into string format. - * If @a ipaddr_format is ttrue this produces "ip-number:port-number" + * If @a ipaddr_format is true this produces "ip-number:port-number" * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false * this produces "ip-name:port-number" (e.g., * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the @@ -347,6 +352,13 @@ public: /// Computes and returns hash value. virtual u_long hash (void) const; + /// If there is another address to examine, move to it and return true; + /// else return false. + bool next (void); + + /// Reset the set of address so they can be scanned again using next(). + void reset (void); + /// Dump the state of an object. void dump (void) const; @@ -364,18 +376,22 @@ private: int determine_type (void) const; /// Initialize underlying inet_addr_ to default values - void reset (void); + void reset_i (void); /// Underlying representation. /// This union uses the knowledge that the two structures share the /// first member, sa_family (as all sockaddr structures do). - union + union ip46 { sockaddr_in in4_; #if defined (ACE_HAS_IPV6) sockaddr_in6 in6_; #endif /* ACE_HAS_IPV6 */ } inet_addr_; + // If there is more than one address assigned to a given name, this + // holds all of them; one is always copied to inet_addr_. + std::vector inet_addrs_; + std::vector::iterator inet_addrs_iter_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/INET_Addr.inl b/ACE/ace/INET_Addr.inl index 6cc14c97558..2532bb9cb6f 100644 --- a/ACE/ace/INET_Addr.inl +++ b/ACE/ace/INET_Addr.inl @@ -7,7 +7,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void -ACE_INET_Addr::reset (void) +ACE_INET_Addr::reset_i (void) { ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->get_type() == AF_INET) diff --git a/ACE/ace/Multihomed_INET_Addr.cpp b/ACE/ace/Multihomed_INET_Addr.cpp index a734beb1ae2..1acc40c1053 100644 --- a/ACE/ace/Multihomed_INET_Addr.cpp +++ b/ACE/ace/Multihomed_INET_Addr.cpp @@ -243,21 +243,40 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs, size_t size) const { - // Copy primary address to the first slot of the user-supplied array - if (size > 0) { - addrs[0] = *reinterpret_cast (this->get_addr ()); - } + if (size == 0) + return; + // Copy primary address(es) to the first slot(s) of the user-supplied array + ACE_INET_Addr me (*this); + size_t i = 0; + for (i = 0; i < size; ++i) + { + sockaddr_in *in4 = reinterpret_cast (me.get_addr ()); + if (in4->sin_family == AF_INET) + { + addrs[i] = *in4; + ++i; + } + if (!me.next ()) + break; + } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - - size_t top = size - 1 < this->secondaries_.size() ? - size - 1 : this->secondaries_.size(); - - for (size_t i = 0; i < top; ++i) { - addrs[i+1] = - *reinterpret_cast (this->secondaries_[i].get_addr()); - } + for (size_t j = 0; j < this->secondaries_.size (); ++j) + { + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in *in4 = reinterpret_cast (copy.get_addr ()); + if (in4->sin_family == AF_INET) + { + addrs[i] = *in4; + ++i; + } + if (!copy.next ()) + break; + } + } } #if defined (ACE_HAS_IPV6) @@ -265,22 +284,40 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs, size_t size) const { - // Copy primary address to the first slot of the user-supplied array - if (size > 0) + if (size == 0) + return; + // Copy primary address(es) to the first slot(s) of the user-supplied array + ACE_INET_Addr me (*this); + size_t i = 0; + for (i = 0; i < size; ++i) { - addrs[0] = *reinterpret_cast (this->get_addr ()); + sockaddr_in6 *in6 = reinterpret_cast (me.get_addr ()); + if (in6->sin6_family == AF_INET6) + { + addrs[i] = *in6; + ++i; + } + if (!me.next ()) + break; } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - size_t top = - size - 1 < this->secondaries_.size() ? - size - 1 : this->secondaries_.size(); - - for (size_t i = 0; i < top; ++i) + for (size_t j = 0; j < this->secondaries_.size (); ++j) { - addrs[i+1] = - *reinterpret_cast (this->secondaries_[i].get_addr()); + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in6 *in6 = + reinterpret_cast (copy.get_addr ()); + if (in6->sin6_family == AF_INET6) + { + addrs[i] = *in6; + ++i; + } + if (!copy.next ()) + break; + } } } #endif /* ACE_HAS_IPV6 */ diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index 4743b2894f3..9e2cfc7a4a9 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -20,7 +20,7 @@ // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. -int check_type_consistency (const ACE_INET_Addr &addr) +static int check_type_consistency (const ACE_INET_Addr &addr) { int family = -1; @@ -49,6 +49,52 @@ int check_type_consistency (const ACE_INET_Addr &addr) return 0; } +static bool test_multiple (void) +{ + + bool success = true; + + // Check the behavior when there are multiple addresses assigned to a name. + // The NTP pool should always return multiples, though always different. + ACE_INET_Addr ntp; + if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org"))); + return false; + } + size_t count = 0; + ACE_TCHAR addr_string[256]; + do + { + ++count; // If lookup succeeded, there's at least one + ntp.addr_to_string (addr_string, sizeof (addr_string)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string)); + } + while (ntp.next ()); + success = count > 1; + +#if defined (ACE_HAS_IPV6) + ACE_INET_Addr ntp6; + if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org"))); + return false; + } + count = 0; + do + { + ++count; // If lookup succeeded, there's at least one + ntp6.addr_to_string (addr_string, sizeof (addr_string)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string)); + } + while (ntp6.next ()); + if (count <= 1) + success = false; +#endif /* ACE_HAS_IPV6 */ + + return success; +} + struct Address { const char* name; bool loopback; @@ -273,6 +319,9 @@ int run_main (int, ACE_TCHAR *[]) status = 1; } + if (!test_multiple ()) + status = 1; + ACE_END_TEST; return status; -- cgit v1.2.1 From 506127ad1b262cc79d36febcc4dc03faa1f90f65 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 6 Mar 2015 17:07:53 -0600 Subject: Updated .gitignore files --- ACE/tests/.gitignore | 1 + TAO/orbsvcs/ImplRepo_Service/.gitignore | 2 ++ TAO/tests/Hello/.gitignore | 7 ++++++- TAO/utils/nslist/.gitignore | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ACE/tests/.gitignore b/ACE/tests/.gitignore index 3fb4c3d8a60..f21f84dc116 100644 --- a/ACE/tests/.gitignore +++ b/ACE/tests/.gitignore @@ -111,6 +111,7 @@ /RB_Tree_Test /Reactor_Dispatch_Order_Test /Reactor_Exceptions_Test +/Reactor_Fairness_Test /Reactor_Notification_Queue_Test /Reactor_Notify_Test /Reactor_Performance_Test diff --git a/TAO/orbsvcs/ImplRepo_Service/.gitignore b/TAO/orbsvcs/ImplRepo_Service/.gitignore index b242352b30d..fb86511a763 100644 --- a/TAO/orbsvcs/ImplRepo_Service/.gitignore +++ b/TAO/orbsvcs/ImplRepo_Service/.gitignore @@ -24,3 +24,5 @@ /ServerObjectS.cpp /ServerObjectS.h /tao_imr +/tao_imr_activator +/tao_imr_locator diff --git a/TAO/tests/Hello/.gitignore b/TAO/tests/Hello/.gitignore index 414222416ff..9df5b54aa17 100644 --- a/TAO/tests/Hello/.gitignore +++ b/TAO/tests/Hello/.gitignore @@ -1,3 +1,8 @@ -/TestA.cpp /client /server +/TestA.cpp +/TestC.cpp +/TestC.h +/TestC.inl +/TestS.cpp +/TestS.h diff --git a/TAO/utils/nslist/.gitignore b/TAO/utils/nslist/.gitignore index 9fc9e3a09b1..fb8a8177444 100644 --- a/TAO/utils/nslist/.gitignore +++ b/TAO/utils/nslist/.gitignore @@ -1,3 +1,6 @@ /nsadd /nsdel /nslist +/tao_nsadd +/tao_nsdel +/tao_nslist -- cgit v1.2.1 From 421f5c292adc9de925aec7c3a51e4cd4904d288e Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Fri, 6 Mar 2015 17:09:04 -0600 Subject: Prevent running depgen twice during "make depend" --- ACE/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm b/ACE/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm index d7e63a1ed83..ba664a183c2 100644 --- a/ACE/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm +++ b/ACE/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm @@ -99,7 +99,7 @@ sub write_comps { if ($named) { $self->write_named_targets($fh, $crlf, \%targnum, \@list, 'REMAINING_TARGETS := ' . - '$(filter-out all,$(TARGETS_NESTED:.nested=)) $(CUSTOM_TARGETS)' . + '$(filter-out all depend,$(TARGETS_NESTED:.nested=)) $(CUSTOM_TARGETS)' . "$crlf$crlf\$(REMAINING_TARGETS)", '', '', $self->project_target_translation(1), 1); } -- cgit v1.2.1 From e9b8c7b5551a1b3341e29b6555da02ce2dc18c25 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 9 Mar 2015 09:06:00 +0100 Subject: Add new package --- ACE/docs/bczar/bczar.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/docs/bczar/bczar.html b/ACE/docs/bczar/bczar.html index 81d89e1e159..ef38733e838 100644 --- a/ACE/docs/bczar/bczar.html +++ b/ACE/docs/bczar/bczar.html @@ -118,7 +118,7 @@ If you want to perform a full build with qt support, than run:
    -
  • yum install bison libxerces-c-devel psmisc yum-utils gdb unzip glibc-devel libasan bison redhat-lsb perl-Pod-Usage rubygems clang make patch libcgroup-devel ant setuptool system-config-network-tui system-config-firewall-tui lcov gnuplot java-1.7.0-openjdk git-svn perl svn screen pysvn automake doxygen bzip2 tar gzip openssh graphviz zip libtool gcc-c++ boost-devel valgrind openssl-devel gcc qt4 fltk-devel bzip2-devel rsync openssl lzo-devel zziplib-devel acpid acpi nfs-utils java xerces-c xerces-c-devel mc qt qt-devel icecream ruby ruby-devel lksctp-tools-devel git telnet GitPython NetworkManager wget mailx
  • +
  • yum install rubygem-rmagick bison libxerces-c-devel psmisc yum-utils gdb unzip glibc-devel libasan bison redhat-lsb perl-Pod-Usage rubygems clang make patch libcgroup-devel ant setuptool system-config-network-tui system-config-firewall-tui lcov gnuplot java-1.7.0-openjdk git-svn perl svn screen pysvn automake doxygen bzip2 tar gzip openssh graphviz zip libtool gcc-c++ boost-devel valgrind openssl-devel gcc qt4 fltk-devel bzip2-devel rsync openssl lzo-devel zziplib-devel acpid acpi nfs-utils java xerces-c xerces-c-devel mc qt qt-devel icecream ruby ruby-devel lksctp-tools-devel git telnet GitPython NetworkManager wget mailx
For some optional i686 packages run
    -- cgit v1.2.1 From 36c75b3b5e8fba1e686f51d794a4a7fce9d2bcc7 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 9 Mar 2015 09:06:38 +0100 Subject: Fixed Coverity insufficient function coverage * TAO/orbsvcs/orbsvcs/Event/EC_Per_Supplier_Filter.cpp: --- .../orbsvcs/Event/EC_Per_Supplier_Filter.cpp | 82 +++++++++++----------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/TAO/orbsvcs/orbsvcs/Event/EC_Per_Supplier_Filter.cpp b/TAO/orbsvcs/orbsvcs/Event/EC_Per_Supplier_Filter.cpp index 0e9321ab8c9..bc9d38bc388 100644 --- a/TAO/orbsvcs/orbsvcs/Event/EC_Per_Supplier_Filter.cpp +++ b/TAO/orbsvcs/orbsvcs/Event/EC_Per_Supplier_Filter.cpp @@ -37,10 +37,10 @@ TAO_EC_Per_Supplier_Filter::bind (TAO_EC_ProxyPushConsumer* consumer) { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); - if (this->consumer_ != 0) - return; - - this->consumer_ = consumer; + if (this->consumer_ == 0) + { + this->consumer_ = consumer; + } } void @@ -68,34 +68,34 @@ TAO_EC_Per_Supplier_Filter::connected (TAO_EC_ProxyPushSupplier* supplier) { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); - if (this->consumer_ == 0) - return; - - const RtecEventChannelAdmin::SupplierQOS& pub = - this->consumer_->publications_i (); - - for (CORBA::ULong j = 0; j < pub.publications.length (); ++j) + if (this->consumer_ != 0) { - const RtecEventComm::Event& event = - pub.publications[j].event; + const RtecEventChannelAdmin::SupplierQOS& pub = + this->consumer_->publications_i (); + + for (CORBA::ULong j = 0; j < pub.publications.length (); ++j) + { + const RtecEventComm::Event& event = + pub.publications[j].event; #if TAO_EC_ENABLE_DEBUG_MESSAGES - ORBSVCS_DEBUG ((LM_DEBUG, "Connecting consumer <%x> to <%x>, " - "trying event <%d:%d> ", - supplier, this, - event.header.source, event.header.type)); + ORBSVCS_DEBUG ((LM_DEBUG, "Connecting consumer <%x> to <%x>, " + "trying event <%d:%d> ", + supplier, this, + event.header.source, event.header.type)); #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */ - if (supplier->can_match (event.header)) - { + if (supplier->can_match (event.header)) + { #if TAO_EC_ENABLE_DEBUG_MESSAGES - ORBSVCS_DEBUG ((LM_DEBUG, " matched\n")); + ORBSVCS_DEBUG ((LM_DEBUG, " matched\n")); #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */ - this->collection_->connected (supplier); - return; - } + this->collection_->connected (supplier); + return; + } #if TAO_EC_ENABLE_DEBUG_MESSAGES - ORBSVCS_DEBUG ((LM_DEBUG, " not matched\n")); + ORBSVCS_DEBUG ((LM_DEBUG, " not matched\n")); #endif /* TAO_EC_ENABLED_DEBUG_MESSAGES */ + } } } @@ -104,28 +104,28 @@ TAO_EC_Per_Supplier_Filter::reconnected (TAO_EC_ProxyPushSupplier* supplier) { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); - if (this->consumer_ == 0) - return; - - const RtecEventChannelAdmin::SupplierQOS& pub = - this->consumer_->publications_i (); - - for (CORBA::ULong j = 0; j < pub.publications.length (); ++j) + if (this->consumer_ != 0) { - const RtecEventComm::Event& event = - pub.publications[j].event; + const RtecEventChannelAdmin::SupplierQOS& pub = + this->consumer_->publications_i (); - // ORBSVCS_DEBUG ((LM_DEBUG, "Trying %d:%d in %x\n", - // event.header.source, event.header.type, - // this)); - if (supplier->can_match (event.header)) + for (CORBA::ULong j = 0; j < pub.publications.length (); ++j) { - // ORBSVCS_DEBUG ((LM_DEBUG, " matched %x\n", supplier)); - this->collection_->connected (supplier); - return; + const RtecEventComm::Event& event = + pub.publications[j].event; + + // ORBSVCS_DEBUG ((LM_DEBUG, "Trying %d:%d in %x\n", + // event.header.source, event.header.type, + // this)); + if (supplier->can_match (event.header)) + { + // ORBSVCS_DEBUG ((LM_DEBUG, " matched %x\n", supplier)); + this->collection_->connected (supplier); + return; + } } + this->collection_->disconnected (supplier); } - this->collection_->disconnected (supplier); } void -- cgit v1.2.1 From e46385b9c288a806aaa884ecac621e2896d5914e Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Mon, 9 Mar 2015 10:46:18 +0100 Subject: Suppress conditional jumps in grep --- ACE/bin/valgrind.supp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ACE/bin/valgrind.supp b/ACE/bin/valgrind.supp index 6322f2c9401..f5fa8a33f0f 100644 --- a/ACE/bin/valgrind.supp +++ b/ACE/bin/valgrind.supp @@ -34,6 +34,13 @@ obj:*/bin/grep } +{ + + Memcheck:Cond + ... + obj:*/bin/grep +} + { Memcheck:Leak -- cgit v1.2.1 From 230add9d5e28ae8e15320a6db5b1b6201c9e8c80 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Mon, 9 Mar 2015 09:32:46 -0500 Subject: Fixed coverity warning 1287148 --- ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp b/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp index 04c169234a8..3bc7bd09d13 100644 --- a/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp +++ b/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp @@ -169,7 +169,7 @@ Client::handle_input (ACE_HANDLE handle) ACE_TEXT ("(%t) Client::handle_input handle = %d bytes_read = %d\n"), handle, bytes_read)); - if (bytes_read == -1 && errno == EWOULDBLOCK) + if (bytes_read < 0 && errno == EWOULDBLOCK) { return 0; } -- cgit v1.2.1 From 0fd2998f2484225bbff712fe19d1f9f3593f7e29 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Tue, 10 Mar 2015 13:16:02 -0400 Subject: Fixed fuzz error (found tab). --- ACE/ace/INET_Addr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 2367fb2499d..b9186da8c2c 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -407,7 +407,7 @@ ACE_INET_Addr::set (u_short port_number, if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); - for (curr = res; curr; curr = curr->ai_next) + for (curr = res; curr; curr = curr->ai_next) { union ip46 next_addr; if (curr->ai_family == AF_INET6) -- cgit v1.2.1 From a2e1e99de25f12b4efc30278838ebdb7bb6f3011 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Wed, 11 Mar 2015 08:47:45 +0100 Subject: Revert "Add ability for ACE_INET_Addr to hold all the addresses assigned to a na..." --- ACE/NEWS | 10 --- ACE/ace/INET_Addr.cpp | 156 +++++++++++++-------------------------- ACE/ace/INET_Addr.h | 26 ++----- ACE/ace/INET_Addr.inl | 2 +- ACE/ace/Multihomed_INET_Addr.cpp | 81 ++++++-------------- ACE/tests/INET_Addr_Test.cpp | 51 +------------ 6 files changed, 79 insertions(+), 247 deletions(-) diff --git a/ACE/NEWS b/ACE/NEWS index 2e2cb9b4628..ead8d8db44f 100644 --- a/ACE/NEWS +++ b/ACE/NEWS @@ -8,16 +8,6 @@ USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 supported. Please see tests/Chrono_Test.cpp for more details. -. Allow ACE_INET_Addr to hold all addresses associated with a hostname. The - set of addresses always has a "current" address which is accessed by the - usual "get"-type methods on the class. Two new methods are added to deal - with multiple addresses: - - bool next (void): makes the next available address the "current" one. - Returns false if there are no more addresses. - - void reset (void): resets the iteration mechanism to be able to examine - all of the addresses again. - ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() - methods copy all available addresses related to each name. USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index b9186da8c2c..1c422fdb899 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -152,31 +152,11 @@ ACE_INET_Addr::hash (void) const return this->get_ip_address () + this->get_port_number (); } -bool -ACE_INET_Addr::next (void) -{ - if (this->inet_addrs_.empty () || - this->inet_addrs_iter_ == this->inet_addrs_.end ()) - return false; - - union ip46 next_a = *this->inet_addrs_iter_++; - this->set_addr (&next_a, sizeof (next_a)); - return true; -} - -void -ACE_INET_Addr::reset (void) -{ - this->inet_addrs_iter_ = this->inet_addrs_.begin (); - this->next (); - return; -} - ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); } int @@ -196,8 +176,6 @@ ACE_INET_Addr::set (const ACE_INET_Addr &sa) this->set_type (sa.get_type()); this->set_size (sa.get_size()); - this->inet_addrs_ = sa.inet_addrs_; - this->reset (); } return 0; @@ -288,7 +266,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (address, address_family); } @@ -297,7 +275,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (address, address_family); } @@ -309,7 +287,7 @@ ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) : ACE_Addr (sa.get_type (), sa.get_size()) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (sa); } @@ -376,22 +354,15 @@ ACE_INET_Addr::set (u_short port_number, { if (hp != 0) { + struct sockaddr_in6 v6; + ACE_OS::memset (&v6, 0, sizeof (v6)); + v6.sin6_family = AF_INET6; + (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, + hp->h_addr, + hp->h_length); this->set_type (hp->h_addrtype); - for (size_t i = 0; hp->h_addr_list[i]; ++i) - { - union ip46 next_addr; - struct sockaddr_in6 *next_addr_in6 = (struct sockaddr_in6 *)&next_addr.in6_; - (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); - next_addr_in6->sin6_family = AF_INET6; - next_addr_in6->sin6_port = - encode ? ACE_NTOHS (port_number) : port_number; - (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr, - hp->h_addr_list[i], - hp->h_length); - this->inet_addrs_.push_back (next_addr); - } - this->reset (); - + this->set_addr (&v6, hp->h_length); + this->set_port_number (port_number, encode); return 0; } } @@ -400,35 +371,16 @@ ACE_INET_Addr::set (u_short port_number, return -1; # else struct addrinfo hints; - struct addrinfo *res = 0, *curr = 0; + struct addrinfo *res = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); - for (curr = res; curr; curr = curr->ai_next) - { - union ip46 next_addr; - if (curr->ai_family == AF_INET6) - { - ACE_OS::memcpy (&next_addr.in6_, - curr->ai_addr, - curr->ai_addrlen); - next_addr.in6_.sin6_port = - encode ? ACE_NTOHS (port_number) : port_number; - } - else - { - ACE_OS::memcpy (&next_addr.in4_, - curr->ai_addr, - curr->ai_addrlen); - next_addr.in4_.sin_port = - encode ? ACE_NTOHS (port_number) : port_number; - } - this->inet_addrs_.push_back (next_addr); - } - this->reset (); + this->set_addr (res->ai_addr, + ACE_Utils::truncate_cast(res->ai_addrlen)); + this->set_port_number (port_number, encode); ::freeaddrinfo (res); return 0; } @@ -454,40 +406,34 @@ ACE_INET_Addr::set (u_short port_number, struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + else { - this->inet_addrs_iter_ = this->inet_addrs_.end (); - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - } - - hostent hentry; - ACE_HOSTENT_DATA buf; - int h_error = 0; // Not the same as errno! + hostent hentry; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! - hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, - buf, &h_error); - if (hp == 0) - { - errno = h_error; - return -1; - } + hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, + buf, &h_error); + if (hp == 0) + errno = h_error; - this->set_type (hp->h_addrtype); - for (size_t i = 0; hp->h_addr_list[i]; ++i) - { - union ip46 next_addr; - struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_; - (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); - next_addr_in->sin_family = AF_INET; - next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number; - (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr, - hp->h_addr_list[i], - hp->h_length); - this->inet_addrs_.push_back (next_addr); + if (hp == 0) + { + return -1; + } + else + { + (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, + hp->h_addr, + hp->h_length); + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + } } - this->reset (); - return 0; } // Helper function to get a port number from a port name. @@ -663,18 +609,17 @@ ACE_INET_Addr::get_addr (void) const } void -ACE_INET_Addr::set_addr (const void *addr, int len) +ACE_INET_Addr::set_addr (void *addr, int len) { this->set_addr (addr, len, 0); } // Set a pointer to the address. void -ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) +ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) { ACE_TRACE ("ACE_INET_Addr::set_addr"); - const struct sockaddr_in *getfamily = - static_cast (addr); + struct sockaddr_in *getfamily = static_cast (addr); if (getfamily->sin_family == AF_INET) { @@ -692,8 +637,7 @@ ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) #if defined (ACE_HAS_IPV6) else if (getfamily->sin_family == AF_INET6) { - const struct sockaddr_in6 *in6 = - static_cast (addr); + struct sockaddr_in6 *in6 = static_cast (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast (&in6->sin6_addr), sizeof (in6->sin6_addr), @@ -709,7 +653,7 @@ ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (addr, len); } @@ -720,7 +664,7 @@ ACE_INET_Addr::ACE_INET_Addr (u_short port_number, : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -736,7 +680,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, host_name, protocol) == -1) @@ -751,7 +695,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, host_name, protocol) == -1) @@ -768,7 +712,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -783,7 +727,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h index 357eac3f0d2..0c21df7b75b 100644 --- a/ACE/ace/INET_Addr.h +++ b/ACE/ace/INET_Addr.h @@ -19,7 +19,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -28,10 +27,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Defines a C++ wrapper facade for the Internet domain address * family format. - * - * ACE_INET_Addr can hold all of the IP addresses assigned to a single name. - * By default it refers only to the first, if there is more than one. The - * next() method can make the others available in turn. */ class ACE_Export ACE_INET_Addr : public ACE_Addr { @@ -194,14 +189,14 @@ public: int get_addr_size(void) const; /// Set a pointer to the address. - virtual void set_addr (const void *, int len); + virtual void set_addr (void *, int len); /// Set a pointer to the address. - virtual void set_addr (const void *, int len, int map); + virtual void set_addr (void *, int len, int map); /** * Transform the current ACE_INET_Addr address into string format. - * If @a ipaddr_format is true this produces "ip-number:port-number" + * If @a ipaddr_format is ttrue this produces "ip-number:port-number" * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false * this produces "ip-name:port-number" (e.g., * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the @@ -352,13 +347,6 @@ public: /// Computes and returns hash value. virtual u_long hash (void) const; - /// If there is another address to examine, move to it and return true; - /// else return false. - bool next (void); - - /// Reset the set of address so they can be scanned again using next(). - void reset (void); - /// Dump the state of an object. void dump (void) const; @@ -376,22 +364,18 @@ private: int determine_type (void) const; /// Initialize underlying inet_addr_ to default values - void reset_i (void); + void reset (void); /// Underlying representation. /// This union uses the knowledge that the two structures share the /// first member, sa_family (as all sockaddr structures do). - union ip46 + union { sockaddr_in in4_; #if defined (ACE_HAS_IPV6) sockaddr_in6 in6_; #endif /* ACE_HAS_IPV6 */ } inet_addr_; - // If there is more than one address assigned to a given name, this - // holds all of them; one is always copied to inet_addr_. - std::vector inet_addrs_; - std::vector::iterator inet_addrs_iter_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/INET_Addr.inl b/ACE/ace/INET_Addr.inl index 2532bb9cb6f..6cc14c97558 100644 --- a/ACE/ace/INET_Addr.inl +++ b/ACE/ace/INET_Addr.inl @@ -7,7 +7,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void -ACE_INET_Addr::reset_i (void) +ACE_INET_Addr::reset (void) { ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->get_type() == AF_INET) diff --git a/ACE/ace/Multihomed_INET_Addr.cpp b/ACE/ace/Multihomed_INET_Addr.cpp index 1acc40c1053..a734beb1ae2 100644 --- a/ACE/ace/Multihomed_INET_Addr.cpp +++ b/ACE/ace/Multihomed_INET_Addr.cpp @@ -243,40 +243,21 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs, size_t size) const { - if (size == 0) - return; - // Copy primary address(es) to the first slot(s) of the user-supplied array - ACE_INET_Addr me (*this); - size_t i = 0; - for (i = 0; i < size; ++i) - { - sockaddr_in *in4 = reinterpret_cast (me.get_addr ()); - if (in4->sin_family == AF_INET) - { - addrs[i] = *in4; - ++i; - } - if (!me.next ()) - break; - } + // Copy primary address to the first slot of the user-supplied array + if (size > 0) { + addrs[0] = *reinterpret_cast (this->get_addr ()); + } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - for (size_t j = 0; j < this->secondaries_.size (); ++j) - { - ACE_INET_Addr copy (this->secondaries_[j]); - for (; i < size; ++i) - { - sockaddr_in *in4 = reinterpret_cast (copy.get_addr ()); - if (in4->sin_family == AF_INET) - { - addrs[i] = *in4; - ++i; - } - if (!copy.next ()) - break; - } - } + + size_t top = size - 1 < this->secondaries_.size() ? + size - 1 : this->secondaries_.size(); + + for (size_t i = 0; i < top; ++i) { + addrs[i+1] = + *reinterpret_cast (this->secondaries_[i].get_addr()); + } } #if defined (ACE_HAS_IPV6) @@ -284,40 +265,22 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs, size_t size) const { - if (size == 0) - return; - // Copy primary address(es) to the first slot(s) of the user-supplied array - ACE_INET_Addr me (*this); - size_t i = 0; - for (i = 0; i < size; ++i) + // Copy primary address to the first slot of the user-supplied array + if (size > 0) { - sockaddr_in6 *in6 = reinterpret_cast (me.get_addr ()); - if (in6->sin6_family == AF_INET6) - { - addrs[i] = *in6; - ++i; - } - if (!me.next ()) - break; + addrs[0] = *reinterpret_cast (this->get_addr ()); } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - for (size_t j = 0; j < this->secondaries_.size (); ++j) + size_t top = + size - 1 < this->secondaries_.size() ? + size - 1 : this->secondaries_.size(); + + for (size_t i = 0; i < top; ++i) { - ACE_INET_Addr copy (this->secondaries_[j]); - for (; i < size; ++i) - { - sockaddr_in6 *in6 = - reinterpret_cast (copy.get_addr ()); - if (in6->sin6_family == AF_INET6) - { - addrs[i] = *in6; - ++i; - } - if (!copy.next ()) - break; - } + addrs[i+1] = + *reinterpret_cast (this->secondaries_[i].get_addr()); } } #endif /* ACE_HAS_IPV6 */ diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index 9e2cfc7a4a9..4743b2894f3 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -20,7 +20,7 @@ // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. -static int check_type_consistency (const ACE_INET_Addr &addr) +int check_type_consistency (const ACE_INET_Addr &addr) { int family = -1; @@ -49,52 +49,6 @@ static int check_type_consistency (const ACE_INET_Addr &addr) return 0; } -static bool test_multiple (void) -{ - - bool success = true; - - // Check the behavior when there are multiple addresses assigned to a name. - // The NTP pool should always return multiples, though always different. - ACE_INET_Addr ntp; - if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1) - { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org"))); - return false; - } - size_t count = 0; - ACE_TCHAR addr_string[256]; - do - { - ++count; // If lookup succeeded, there's at least one - ntp.addr_to_string (addr_string, sizeof (addr_string)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string)); - } - while (ntp.next ()); - success = count > 1; - -#if defined (ACE_HAS_IPV6) - ACE_INET_Addr ntp6; - if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1) - { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org"))); - return false; - } - count = 0; - do - { - ++count; // If lookup succeeded, there's at least one - ntp6.addr_to_string (addr_string, sizeof (addr_string)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string)); - } - while (ntp6.next ()); - if (count <= 1) - success = false; -#endif /* ACE_HAS_IPV6 */ - - return success; -} - struct Address { const char* name; bool loopback; @@ -319,9 +273,6 @@ int run_main (int, ACE_TCHAR *[]) status = 1; } - if (!test_multiple ()) - status = 1; - ACE_END_TEST; return status; -- cgit v1.2.1 From 9f0291524be7646f49e5e29d56c8d548f003f151 Mon Sep 17 00:00:00 2001 From: Marcel Smit Date: Thu, 12 Mar 2015 09:06:53 +0100 Subject: Set is_default_qos to false. One should explicitly set the qos_profile string in the deployment plan. Since this is consistently done, we can set the is_default_qos to false. * CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/examples/ShapesContr/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/performance-tests/DDSLatency/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/performance-tests/DDSThroughput/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/performance-tests/Keyed/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/performance-tests/Latency/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/performance-tests/Throughput/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/CSLDeadline/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/CSLQoS/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/CSLSampleRejected/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/CSLUnexpStat/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/CoherentUpdater/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/CoherentWriter/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/ContentFilteredTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/Getter/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/HomeTest/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/KeyedWriter/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/LateBinding/ReadGet/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/ListenManyByMany/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/PSLDeadline/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/PSLSampleLost/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/Proxies/ReadWrite/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QosProfile/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QueryCondition/DDS/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QueryCondition/DDS_OneByOne/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QueryCondition/Different/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QueryCondition/ReadGet/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueries/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueriesMany/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/Reader/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/ResetTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/SLManyByMany/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/SLOneByOne/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDatatype/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDomainID/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/SameDatatype/descriptors/USER_QOS_PROFILES.xml: * CIAO/connectors/dds4ccm/tests/UnkeyedWriter/descriptors/USER_QOS_PROFILES.xml: * DAnCE/tools/Logger_Backend/ndds/USER_QOS_PROFILES.xml: --- .../IDL2CPPWrapper/Shapes/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/examples/ShapesContr/descriptors/USER_QOS_PROFILES.xml | 2 +- .../performance-tests/DDSLatency/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../DDSThroughput/descriptors/USER_QOS_PROFILES.xml | 6 +++--- .../performance-tests/Keyed/descriptors/USER_QOS_PROFILES.xml | 2 +- .../performance-tests/Latency/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../performance-tests/Throughput/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../dds4ccm/tests/CSLDeadline/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/CSLQoS/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../tests/CSLSampleRejected/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/CSLUnexpStat/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/CoherentUpdater/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/CoherentWriter/descriptors/USER_QOS_PROFILES.xml | 2 +- .../ContentFilteredTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/Getter/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/HomeTest/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/KeyedWriter/descriptors/USER_QOS_PROFILES.xml | 2 +- .../tests/LateBinding/ReadGet/descriptors/USER_QOS_PROFILES.xml | 2 +- .../tests/ListenManyByMany/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/PSLDeadline/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/PSLSampleLost/descriptors/USER_QOS_PROFILES.xml | 2 +- .../tests/Proxies/ReadWrite/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/QosProfile/descriptors/USER_QOS_PROFILES.xml | 2 +- .../tests/QueryCondition/DDS/descriptors/USER_QOS_PROFILES.xml | 2 +- .../QueryCondition/DDS_OneByOne/descriptors/USER_QOS_PROFILES.xml | 2 +- .../QueryCondition/Different/descriptors/USER_QOS_PROFILES.xml | 2 +- .../tests/QueryCondition/ReadGet/descriptors/USER_QOS_PROFILES.xml | 2 +- .../QueryCondition/TwoQueries/descriptors/USER_QOS_PROFILES.xml | 2 +- .../QueryCondition/TwoQueriesMany/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/Reader/descriptors/USER_QOS_PROFILES.xml | 2 +- .../tests/ResetTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/SLManyByMany/descriptors/USER_QOS_PROFILES.xml | 2 +- .../dds4ccm/tests/SLOneByOne/descriptors/USER_QOS_PROFILES.xml | 2 +- .../DifferentDatatype/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../DifferentDomainID/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../SameDatatype/descriptors/USER_QOS_PROFILES.xml | 4 ++-- .../dds4ccm/tests/UnkeyedWriter/descriptors/USER_QOS_PROFILES.xml | 2 +- DAnCE/tools/Logger_Backend/ndds/USER_QOS_PROFILES.xml | 2 +- 38 files changed, 47 insertions(+), 47 deletions(-) diff --git a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/USER_QOS_PROFILES.xml index d47b16c293b..3d764fe83c7 100644 --- a/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/examples/IDL2CPPWrapper/Shapes/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/examples/ShapesContr/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/examples/ShapesContr/descriptors/USER_QOS_PROFILES.xml index 9d7103a914e..869924df719 100644 --- a/CIAO/connectors/dds4ccm/examples/ShapesContr/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/examples/ShapesContr/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/performance-tests/DDSLatency/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/performance-tests/DDSLatency/descriptors/USER_QOS_PROFILES.xml index 56908409148..9f9ee918fd3 100644 --- a/CIAO/connectors/dds4ccm/performance-tests/DDSLatency/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/performance-tests/DDSLatency/descriptors/USER_QOS_PROFILES.xml @@ -31,7 +31,7 @@ A QoS profile groups a set of related QoS. --> - + @@ -126,7 +126,7 @@ - + DDS_TRANSPORTBUILTIN_SHMEM diff --git a/CIAO/connectors/dds4ccm/performance-tests/DDSThroughput/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/performance-tests/DDSThroughput/descriptors/USER_QOS_PROFILES.xml index b24290e6c96..970433834aa 100644 --- a/CIAO/connectors/dds4ccm/performance-tests/DDSThroughput/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/performance-tests/DDSThroughput/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + @@ -51,7 +51,7 @@ RTI Data Distribution Service user manual. - + @@ -105,7 +105,7 @@ RTI Data Distribution Service user manual. - + diff --git a/CIAO/connectors/dds4ccm/performance-tests/Keyed/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/performance-tests/Keyed/descriptors/USER_QOS_PROFILES.xml index 2b76b6f08e1..aa0e70c5999 100644 --- a/CIAO/connectors/dds4ccm/performance-tests/Keyed/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/performance-tests/Keyed/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/performance-tests/Latency/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/performance-tests/Latency/descriptors/USER_QOS_PROFILES.xml index 56908409148..9f9ee918fd3 100644 --- a/CIAO/connectors/dds4ccm/performance-tests/Latency/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/performance-tests/Latency/descriptors/USER_QOS_PROFILES.xml @@ -31,7 +31,7 @@ A QoS profile groups a set of related QoS. --> - + @@ -126,7 +126,7 @@ - + DDS_TRANSPORTBUILTIN_SHMEM diff --git a/CIAO/connectors/dds4ccm/performance-tests/Throughput/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/performance-tests/Throughput/descriptors/USER_QOS_PROFILES.xml index 0e1ffccf022..3016673f87c 100644 --- a/CIAO/connectors/dds4ccm/performance-tests/Throughput/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/performance-tests/Throughput/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + @@ -82,7 +82,7 @@ RTI Data Distribution Service user manual. - + diff --git a/CIAO/connectors/dds4ccm/tests/CSLDeadline/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/CSLDeadline/descriptors/USER_QOS_PROFILES.xml index 1c125f14f6d..e6facde6f0b 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLDeadline/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/CSLDeadline/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/CSLQoS/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/CSLQoS/descriptors/USER_QOS_PROFILES.xml index 0fdacd078d6..2109e905309 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLQoS/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/CSLQoS/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + @@ -56,7 +56,7 @@ RTI Data Distribution Service user manual. - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/CSLSampleRejected/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/CSLSampleRejected/descriptors/USER_QOS_PROFILES.xml index e69ce5ae926..76c111f3515 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLSampleRejected/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/CSLSampleRejected/descriptors/USER_QOS_PROFILES.xml @@ -30,7 +30,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/descriptors/USER_QOS_PROFILES.xml index c07018d1d6e..f2bf87beddf 100644 --- a/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/CSLUnexpStat/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/CoherentUpdater/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/CoherentUpdater/descriptors/USER_QOS_PROFILES.xml index ad81f2e6850..d46728dbf53 100644 --- a/CIAO/connectors/dds4ccm/tests/CoherentUpdater/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/CoherentUpdater/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/CoherentWriter/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/CoherentWriter/descriptors/USER_QOS_PROFILES.xml index 8054b3eeee1..92bb5c31801 100644 --- a/CIAO/connectors/dds4ccm/tests/CoherentWriter/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/CoherentWriter/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/ContentFilteredTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/ContentFilteredTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml index ea26f3b83c2..75007b4404d 100644 --- a/CIAO/connectors/dds4ccm/tests/ContentFilteredTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/ContentFilteredTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/Getter/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/Getter/descriptors/USER_QOS_PROFILES.xml index b2db6d4f1f9..a2ea7207800 100644 --- a/CIAO/connectors/dds4ccm/tests/Getter/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/Getter/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/HomeTest/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/HomeTest/descriptors/USER_QOS_PROFILES.xml index dfd4b8a30ef..6efbf0f6fb3 100644 --- a/CIAO/connectors/dds4ccm/tests/HomeTest/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/HomeTest/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/KeyedWriter/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/KeyedWriter/descriptors/USER_QOS_PROFILES.xml index 25ca3d326ec..01b07188022 100644 --- a/CIAO/connectors/dds4ccm/tests/KeyedWriter/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/KeyedWriter/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/LateBinding/ReadGet/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/LateBinding/ReadGet/descriptors/USER_QOS_PROFILES.xml index 5ac842d55d7..84fcb573f76 100644 --- a/CIAO/connectors/dds4ccm/tests/LateBinding/ReadGet/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/LateBinding/ReadGet/descriptors/USER_QOS_PROFILES.xml @@ -4,7 +4,7 @@ - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/ListenManyByMany/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/ListenManyByMany/descriptors/USER_QOS_PROFILES.xml index c0cfedb62d1..ad8bc8ed52f 100644 --- a/CIAO/connectors/dds4ccm/tests/ListenManyByMany/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/ListenManyByMany/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/PSLDeadline/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/PSLDeadline/descriptors/USER_QOS_PROFILES.xml index 055636f35cc..1e1d74d6186 100644 --- a/CIAO/connectors/dds4ccm/tests/PSLDeadline/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/PSLDeadline/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/PSLSampleLost/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/PSLSampleLost/descriptors/USER_QOS_PROFILES.xml index 5001d3340a9..1c599ab21db 100644 --- a/CIAO/connectors/dds4ccm/tests/PSLSampleLost/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/PSLSampleLost/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/Proxies/ReadWrite/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/Proxies/ReadWrite/descriptors/USER_QOS_PROFILES.xml index 19948c6d085..1f6edf73025 100644 --- a/CIAO/connectors/dds4ccm/tests/Proxies/ReadWrite/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/Proxies/ReadWrite/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/QosProfile/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QosProfile/descriptors/USER_QOS_PROFILES.xml index 3fd3bfeff99..7652e49300c 100644 --- a/CIAO/connectors/dds4ccm/tests/QosProfile/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QosProfile/descriptors/USER_QOS_PROFILES.xml @@ -4,7 +4,7 @@ - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS/descriptors/USER_QOS_PROFILES.xml index dd5f83468ab..24d6b2eb8f3 100644 --- a/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS/descriptors/USER_QOS_PROFILES.xml @@ -30,7 +30,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS_OneByOne/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS_OneByOne/descriptors/USER_QOS_PROFILES.xml index dd5f83468ab..24d6b2eb8f3 100644 --- a/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS_OneByOne/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QueryCondition/DDS_OneByOne/descriptors/USER_QOS_PROFILES.xml @@ -30,7 +30,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/QueryCondition/Different/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QueryCondition/Different/descriptors/USER_QOS_PROFILES.xml index ea26f3b83c2..75007b4404d 100644 --- a/CIAO/connectors/dds4ccm/tests/QueryCondition/Different/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QueryCondition/Different/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/QueryCondition/ReadGet/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QueryCondition/ReadGet/descriptors/USER_QOS_PROFILES.xml index ea26f3b83c2..75007b4404d 100644 --- a/CIAO/connectors/dds4ccm/tests/QueryCondition/ReadGet/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QueryCondition/ReadGet/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueries/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueries/descriptors/USER_QOS_PROFILES.xml index ea26f3b83c2..75007b4404d 100644 --- a/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueries/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueries/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueriesMany/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueriesMany/descriptors/USER_QOS_PROFILES.xml index bad6029914a..dc3a57f133d 100644 --- a/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueriesMany/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/QueryCondition/TwoQueriesMany/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/Reader/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/Reader/descriptors/USER_QOS_PROFILES.xml index 7afea6a6fc1..a3245c44987 100644 --- a/CIAO/connectors/dds4ccm/tests/Reader/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/Reader/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/ResetTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/ResetTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml index 75b8d3b79de..e3268d2c621 100644 --- a/CIAO/connectors/dds4ccm/tests/ResetTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/ResetTopic/ReadGet/descriptors/USER_QOS_PROFILES.xml @@ -2,7 +2,7 @@ - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/SLManyByMany/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/SLManyByMany/descriptors/USER_QOS_PROFILES.xml index 20f8adc70d1..55f7c22419e 100644 --- a/CIAO/connectors/dds4ccm/tests/SLManyByMany/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/SLManyByMany/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/SLOneByOne/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/SLOneByOne/descriptors/USER_QOS_PROFILES.xml index 983fd474490..e1a8f96ecfd 100644 --- a/CIAO/connectors/dds4ccm/tests/SLOneByOne/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/SLOneByOne/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDatatype/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDatatype/descriptors/USER_QOS_PROFILES.xml index e125eab41aa..f1018e84958 100644 --- a/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDatatype/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDatatype/descriptors/USER_QOS_PROFILES.xml @@ -4,7 +4,7 @@ - + RELIABLE_RELIABILITY_QOS @@ -41,7 +41,7 @@ - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDomainID/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDomainID/descriptors/USER_QOS_PROFILES.xml index e125eab41aa..f1018e84958 100644 --- a/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDomainID/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/DifferentDomainID/descriptors/USER_QOS_PROFILES.xml @@ -4,7 +4,7 @@ - + RELIABLE_RELIABILITY_QOS @@ -41,7 +41,7 @@ - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/SameDatatype/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/SameDatatype/descriptors/USER_QOS_PROFILES.xml index e125eab41aa..f1018e84958 100644 --- a/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/SameDatatype/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/SharedDomainParticipant/SameDatatype/descriptors/USER_QOS_PROFILES.xml @@ -4,7 +4,7 @@ - + RELIABLE_RELIABILITY_QOS @@ -41,7 +41,7 @@ - + RELIABLE_RELIABILITY_QOS diff --git a/CIAO/connectors/dds4ccm/tests/UnkeyedWriter/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/tests/UnkeyedWriter/descriptors/USER_QOS_PROFILES.xml index e9caef47b6f..738d0cbe072 100644 --- a/CIAO/connectors/dds4ccm/tests/UnkeyedWriter/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/tests/UnkeyedWriter/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + diff --git a/DAnCE/tools/Logger_Backend/ndds/USER_QOS_PROFILES.xml b/DAnCE/tools/Logger_Backend/ndds/USER_QOS_PROFILES.xml index 9bfff9471cf..22749c51237 100644 --- a/DAnCE/tools/Logger_Backend/ndds/USER_QOS_PROFILES.xml +++ b/DAnCE/tools/Logger_Backend/ndds/USER_QOS_PROFILES.xml @@ -2,7 +2,7 @@ - + RELIABLE_RELIABILITY_QOS -- cgit v1.2.1 From 3cc55b395c4ff501799c5bb82ef69e36c5f11a72 Mon Sep 17 00:00:00 2001 From: marcelsmit Date: Thu, 12 Mar 2015 09:33:32 +0100 Subject: is_default_qos set to false. * CIAO/connectors/dds4ccm/examples/Hello/descriptors/USER_QOS_PROFILES.xml: --- .../dds4ccm/examples/Hello/descriptors/USER_QOS_PROFILES.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CIAO/connectors/dds4ccm/examples/Hello/descriptors/USER_QOS_PROFILES.xml b/CIAO/connectors/dds4ccm/examples/Hello/descriptors/USER_QOS_PROFILES.xml index dfd4b8a30ef..0facf24ed88 100644 --- a/CIAO/connectors/dds4ccm/examples/Hello/descriptors/USER_QOS_PROFILES.xml +++ b/CIAO/connectors/dds4ccm/examples/Hello/descriptors/USER_QOS_PROFILES.xml @@ -28,7 +28,7 @@ RTI Data Distribution Service user manual. A QoS profile groups a set of related QoS. --> - + @@ -61,4 +61,4 @@ RTI Data Distribution Service user manual. - \ No newline at end of file + -- cgit v1.2.1 From 16e65aee37999efc6cdf01577bffe7ba707eebd3 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Thu, 12 Mar 2015 20:08:20 -0400 Subject: Changes to enable ACE_INET_Addr to hold all addresses for a given name; round 2 with fixes --- ACE/NEWS | 10 ++ ACE/ace/INET_Addr.cpp | 192 +++++++++++++++++++++++++++------------ ACE/ace/INET_Addr.h | 40 +++++++- ACE/ace/INET_Addr.inl | 2 +- ACE/ace/Multihomed_INET_Addr.cpp | 81 ++++++++++++----- 5 files changed, 238 insertions(+), 87 deletions(-) diff --git a/ACE/NEWS b/ACE/NEWS index ead8d8db44f..2e2cb9b4628 100644 --- a/ACE/NEWS +++ b/ACE/NEWS @@ -8,6 +8,16 @@ USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 supported. Please see tests/Chrono_Test.cpp for more details. +. Allow ACE_INET_Addr to hold all addresses associated with a hostname. The + set of addresses always has a "current" address which is accessed by the + usual "get"-type methods on the class. Two new methods are added to deal + with multiple addresses: + - bool next (void): makes the next available address the "current" one. + Returns false if there are no more addresses. + - void reset (void): resets the iteration mechanism to be able to examine + all of the addresses again. + ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() + methods copy all available addresses related to each name. USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 1c422fdb899..96e26b93dcf 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -152,11 +152,38 @@ ACE_INET_Addr::hash (void) const return this->get_ip_address () + this->get_port_number (); } +bool +ACE_INET_Addr::next (void) +{ + if (this->inet_addrs_.empty () || + this->inet_addrs_iter_ == this->inet_addrs_.end ()) + return false; + + union ip46 next_a = *this->inet_addrs_iter_++; + this->set_addr (&next_a, sizeof (next_a)); + return true; +} + +void +ACE_INET_Addr::reset (void) +{ + this->inet_addrs_iter_ = this->inet_addrs_.begin (); + this->next (); + return; +} + ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); +} + +ACE_INET_Addr & +ACE_INET_Addr::operator= (const ACE_INET_Addr& rhs) +{ + this->set (rhs); + return *this; } int @@ -176,6 +203,8 @@ ACE_INET_Addr::set (const ACE_INET_Addr &sa) this->set_type (sa.get_type()); this->set_size (sa.get_size()); + this->inet_addrs_ = sa.inet_addrs_; + this->reset (); } return 0; @@ -266,7 +295,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (address, address_family); } @@ -275,7 +304,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (address, address_family); } @@ -287,7 +316,7 @@ ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) : ACE_Addr (sa.get_type (), sa.get_size()) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (sa); } @@ -354,15 +383,25 @@ ACE_INET_Addr::set (u_short port_number, { if (hp != 0) { - struct sockaddr_in6 v6; - ACE_OS::memset (&v6, 0, sizeof (v6)); - v6.sin6_family = AF_INET6; - (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, - hp->h_addr, - hp->h_length); this->set_type (hp->h_addrtype); - this->set_addr (&v6, hp->h_length); - this->set_port_number (port_number, encode); + for (size_t i = 0; hp->h_addr_list[i]; ++i) + { + union ip46 next_addr; + struct sockaddr_in6 *next_addr_in6 = &next_addr.in6_; + (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr)); + next_addr_in6->sin6_family = AF_INET6; + next_addr_in6->sin6_port = + encode ? ACE_NTOHS (port_number) : port_number; +#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN + next_addr_in6_->sin6_len = hp->h_length; +#endif + (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr, + hp->h_addr_list[i], + hp->h_length); + this->inet_addrs_.push_back (next_addr); + } + this->reset (); + return 0; } } @@ -371,16 +410,35 @@ ACE_INET_Addr::set (u_short port_number, return -1; # else struct addrinfo hints; - struct addrinfo *res = 0; + struct addrinfo *res = 0, *curr = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); - this->set_addr (res->ai_addr, - ACE_Utils::truncate_cast(res->ai_addrlen)); - this->set_port_number (port_number, encode); + for (curr = res; curr; curr = curr->ai_next) + { + union ip46 next_addr; + if (curr->ai_family == AF_INET6) + { + ACE_OS::memcpy (&next_addr.in6_, + curr->ai_addr, + curr->ai_addrlen); + next_addr.in6_.sin6_port = + encode ? ACE_NTOHS (port_number) : port_number; + } + else + { + ACE_OS::memcpy (&next_addr.in4_, + curr->ai_addr, + curr->ai_addrlen); + next_addr.in4_.sin_port = + encode ? ACE_NTOHS (port_number) : port_number; + } + this->inet_addrs_.push_back (next_addr); + } + this->reset (); ::freeaddrinfo (res); return 0; } @@ -406,34 +464,40 @@ ACE_INET_Addr::set (u_short port_number, struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - else { - hostent hentry; - ACE_HOSTENT_DATA buf; - int h_error = 0; // Not the same as errno! + this->inet_addrs_iter_ = this->inet_addrs_.end (); + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + } - hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, - buf, &h_error); - if (hp == 0) - errno = h_error; + hostent hentry; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! - if (hp == 0) - { - return -1; - } - else - { - (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, - hp->h_addr, - hp->h_length); - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - } + hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, + buf, &h_error); + if (hp == 0) + { + errno = h_error; + return -1; + } + + this->set_type (hp->h_addrtype); + for (size_t i = 0; hp->h_addr_list[i]; ++i) + { + union ip46 next_addr; + struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_; + (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); + next_addr_in->sin_family = AF_INET; + next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number; + (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr, + hp->h_addr_list[i], + hp->h_length); + this->inet_addrs_.push_back (next_addr); } + this->reset (); + return 0; } // Helper function to get a port number from a port name. @@ -609,17 +673,18 @@ ACE_INET_Addr::get_addr (void) const } void -ACE_INET_Addr::set_addr (void *addr, int len) +ACE_INET_Addr::set_addr (const void *addr, int len) { this->set_addr (addr, len, 0); } // Set a pointer to the address. void -ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) +ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) { ACE_TRACE ("ACE_INET_Addr::set_addr"); - struct sockaddr_in *getfamily = static_cast (addr); + const struct sockaddr_in *getfamily = + static_cast (addr); if (getfamily->sin_family == AF_INET) { @@ -637,7 +702,8 @@ ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) #if defined (ACE_HAS_IPV6) else if (getfamily->sin_family == AF_INET6) { - struct sockaddr_in6 *in6 = static_cast (addr); + const struct sockaddr_in6 *in6 = + static_cast (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast (&in6->sin6_addr), sizeof (in6->sin6_addr), @@ -653,7 +719,7 @@ ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (addr, len); } @@ -664,7 +730,7 @@ ACE_INET_Addr::ACE_INET_Addr (u_short port_number, : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -680,7 +746,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, host_name, protocol) == -1) @@ -695,7 +761,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, host_name, protocol) == -1) @@ -712,7 +778,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -727,7 +793,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -969,17 +1035,23 @@ int ACE_INET_Addr::set_address (const char *ip_addr, sizeof (ip6)); return 0; } - - // Build up a 128 bit address. An IPv4-mapped IPv6 address - // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined - // in RFC 1884 */ - ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); - this->inet_addr_.in6_.sin6_addr.s6_addr[10] = - this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; - ACE_OS::memcpy - (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); + else + { + // Build up a 128 bit address. An IPv4-mapped IPv6 address + // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined + // in RFC 1884 */ + ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); + this->inet_addr_.in6_.sin6_addr.s6_addr[10] = + this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; + ACE_OS::memcpy + (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); + } } #endif /* ACE_HAS_IPV6 */ + + this->inet_addrs_.clear (); + this->inet_addrs_iter_ = this->inet_addrs_.begin (); + return 0; } /* end if (len == 4) */ #if defined (ACE_HAS_IPV6) @@ -997,6 +1069,8 @@ int ACE_INET_Addr::set_address (const char *ip_addr, this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); #endif ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); + this->inet_addrs_.clear (); + this->inet_addrs_iter_ = this->inet_addrs_.begin (); return 0; } /* end len == 16 */ diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h index 0c21df7b75b..c1a40553754 100644 --- a/ACE/ace/INET_Addr.h +++ b/ACE/ace/INET_Addr.h @@ -19,6 +19,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" +#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -27,6 +28,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Defines a C++ wrapper facade for the Internet domain address * family format. + * + * ACE_INET_Addr can hold all of the IP addresses assigned to a single name. + * By default it refers only to the first, if there is more than one. The + * next() method can make the others available in turn. */ class ACE_Export ACE_INET_Addr : public ACE_Addr { @@ -108,6 +113,20 @@ public: // These methods are useful after the object has been constructed. + /// Assignment. In a more well-ordered world, member-wise assignment would + /// work fine. However, because of the class design feature that all of the + /// acceptor/connector-type classes that can be used in the + /// Acceptor-Connector framework take ACE_Addr objects instead of the + /// addressing class matching the family in use. The mechanism used to + /// enable this substitution to the more-appropriate class is + /// ACE_sap_any_cast, which casts the ACE_Addr to the more-specific class. + /// In this case, casting an ACE_Addr to ACE_INET_Addr then copying it. + /// Since adding multiple address support to ACE_INET_Addr, that cast-copy + /// operation ends up, in the member-wise case, copying a bogus vector + /// and doing lots of random damage. Thus, this operator is used to make + /// life ordered in this common scenario. + ACE_INET_Addr & operator= (const ACE_INET_Addr &rhs); + /// Initializes from another ACE_INET_Addr. int set (const ACE_INET_Addr &); @@ -189,14 +208,14 @@ public: int get_addr_size(void) const; /// Set a pointer to the address. - virtual void set_addr (void *, int len); + virtual void set_addr (const void *, int len); /// Set a pointer to the address. - virtual void set_addr (void *, int len, int map); + virtual void set_addr (const void *, int len, int map); /** * Transform the current ACE_INET_Addr address into string format. - * If @a ipaddr_format is ttrue this produces "ip-number:port-number" + * If @a ipaddr_format is true this produces "ip-number:port-number" * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false * this produces "ip-name:port-number" (e.g., * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the @@ -347,6 +366,13 @@ public: /// Computes and returns hash value. virtual u_long hash (void) const; + /// If there is another address to examine, move to it and return true; + /// else return false. + bool next (void); + + /// Reset the set of address so they can be scanned again using next(). + void reset (void); + /// Dump the state of an object. void dump (void) const; @@ -364,18 +390,22 @@ private: int determine_type (void) const; /// Initialize underlying inet_addr_ to default values - void reset (void); + void reset_i (void); /// Underlying representation. /// This union uses the knowledge that the two structures share the /// first member, sa_family (as all sockaddr structures do). - union + union ip46 { sockaddr_in in4_; #if defined (ACE_HAS_IPV6) sockaddr_in6 in6_; #endif /* ACE_HAS_IPV6 */ } inet_addr_; + // If there is more than one address assigned to a given name, this + // holds all of them; one is always copied to inet_addr_. + std::vector inet_addrs_; + std::vector::iterator inet_addrs_iter_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/INET_Addr.inl b/ACE/ace/INET_Addr.inl index 6cc14c97558..2532bb9cb6f 100644 --- a/ACE/ace/INET_Addr.inl +++ b/ACE/ace/INET_Addr.inl @@ -7,7 +7,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void -ACE_INET_Addr::reset (void) +ACE_INET_Addr::reset_i (void) { ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->get_type() == AF_INET) diff --git a/ACE/ace/Multihomed_INET_Addr.cpp b/ACE/ace/Multihomed_INET_Addr.cpp index a734beb1ae2..1acc40c1053 100644 --- a/ACE/ace/Multihomed_INET_Addr.cpp +++ b/ACE/ace/Multihomed_INET_Addr.cpp @@ -243,21 +243,40 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs, size_t size) const { - // Copy primary address to the first slot of the user-supplied array - if (size > 0) { - addrs[0] = *reinterpret_cast (this->get_addr ()); - } + if (size == 0) + return; + // Copy primary address(es) to the first slot(s) of the user-supplied array + ACE_INET_Addr me (*this); + size_t i = 0; + for (i = 0; i < size; ++i) + { + sockaddr_in *in4 = reinterpret_cast (me.get_addr ()); + if (in4->sin_family == AF_INET) + { + addrs[i] = *in4; + ++i; + } + if (!me.next ()) + break; + } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - - size_t top = size - 1 < this->secondaries_.size() ? - size - 1 : this->secondaries_.size(); - - for (size_t i = 0; i < top; ++i) { - addrs[i+1] = - *reinterpret_cast (this->secondaries_[i].get_addr()); - } + for (size_t j = 0; j < this->secondaries_.size (); ++j) + { + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in *in4 = reinterpret_cast (copy.get_addr ()); + if (in4->sin_family == AF_INET) + { + addrs[i] = *in4; + ++i; + } + if (!copy.next ()) + break; + } + } } #if defined (ACE_HAS_IPV6) @@ -265,22 +284,40 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs, size_t size) const { - // Copy primary address to the first slot of the user-supplied array - if (size > 0) + if (size == 0) + return; + // Copy primary address(es) to the first slot(s) of the user-supplied array + ACE_INET_Addr me (*this); + size_t i = 0; + for (i = 0; i < size; ++i) { - addrs[0] = *reinterpret_cast (this->get_addr ()); + sockaddr_in6 *in6 = reinterpret_cast (me.get_addr ()); + if (in6->sin6_family == AF_INET6) + { + addrs[i] = *in6; + ++i; + } + if (!me.next ()) + break; } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - size_t top = - size - 1 < this->secondaries_.size() ? - size - 1 : this->secondaries_.size(); - - for (size_t i = 0; i < top; ++i) + for (size_t j = 0; j < this->secondaries_.size (); ++j) { - addrs[i+1] = - *reinterpret_cast (this->secondaries_[i].get_addr()); + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in6 *in6 = + reinterpret_cast (copy.get_addr ()); + if (in6->sin6_family == AF_INET6) + { + addrs[i] = *in6; + ++i; + } + if (!copy.next ()) + break; + } } } #endif /* ACE_HAS_IPV6 */ -- cgit v1.2.1 From bfce463fcd2e0e30c4eab6434594efa938ee2d80 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Thu, 12 Mar 2015 20:12:43 -0400 Subject: Add the requisite test program addition for new feature --- ACE/tests/INET_Addr_Test.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index 4743b2894f3..9e2cfc7a4a9 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -20,7 +20,7 @@ // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. -int check_type_consistency (const ACE_INET_Addr &addr) +static int check_type_consistency (const ACE_INET_Addr &addr) { int family = -1; @@ -49,6 +49,52 @@ int check_type_consistency (const ACE_INET_Addr &addr) return 0; } +static bool test_multiple (void) +{ + + bool success = true; + + // Check the behavior when there are multiple addresses assigned to a name. + // The NTP pool should always return multiples, though always different. + ACE_INET_Addr ntp; + if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org"))); + return false; + } + size_t count = 0; + ACE_TCHAR addr_string[256]; + do + { + ++count; // If lookup succeeded, there's at least one + ntp.addr_to_string (addr_string, sizeof (addr_string)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string)); + } + while (ntp.next ()); + success = count > 1; + +#if defined (ACE_HAS_IPV6) + ACE_INET_Addr ntp6; + if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org"))); + return false; + } + count = 0; + do + { + ++count; // If lookup succeeded, there's at least one + ntp6.addr_to_string (addr_string, sizeof (addr_string)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string)); + } + while (ntp6.next ()); + if (count <= 1) + success = false; +#endif /* ACE_HAS_IPV6 */ + + return success; +} + struct Address { const char* name; bool loopback; @@ -273,6 +319,9 @@ int run_main (int, ACE_TCHAR *[]) status = 1; } + if (!test_multiple ()) + status = 1; + ACE_END_TEST; return status; -- cgit v1.2.1 From 135bac34b594c10a2a058e4ad9d799e8e918bc47 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Fri, 13 Mar 2015 10:33:27 -0400 Subject: Add sanity check and test for new operator= --- ACE/ace/INET_Addr.cpp | 3 ++- ACE/tests/INET_Addr_Test.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 96e26b93dcf..f12f3f83ada 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -182,7 +182,8 @@ ACE_INET_Addr::ACE_INET_Addr (void) ACE_INET_Addr & ACE_INET_Addr::operator= (const ACE_INET_Addr& rhs) { - this->set (rhs); + if (this != &rhs) + this->set (rhs); return *this; } diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index 9e2cfc7a4a9..f216789a5bc 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -322,6 +322,15 @@ int run_main (int, ACE_TCHAR *[]) if (!test_multiple ()) status = 1; + ACE_INET_Addr a1 (80, "127.0.0.1"); + ACE_INET_Addr a2 = a1; + if (a1 != a2) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Address equality check failed after assignment\n"))); + status = 1; + } + ACE_END_TEST; return status; -- cgit v1.2.1 From df7bedd75668682974ec8b91074b013860a1a58c Mon Sep 17 00:00:00 2001 From: Like Ma Date: Sat, 14 Mar 2015 14:31:29 +0800 Subject: Fix errno checking logic. --- ACE/ace/ACE.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp index 20e54dab5c9..0e35b2ceb8a 100644 --- a/ACE/ace/ACE.cpp +++ b/ACE/ace/ACE.cpp @@ -1529,7 +1529,7 @@ ACE::t_snd_n_i (ACE_HANDLE handle, { // Check for possible blocking. if (n == -1 && - errno == EWOULDBLOCK || errno == ENOBUFS) + (errno == EWOULDBLOCK || errno == ENOBUFS)) { // Wait upto for the blocking to subside. int const rtn = ACE::handle_write_ready (handle, timeout); -- cgit v1.2.1 From eb4234d05c6817325967348ed438dcf0b62915de Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Sat, 14 Mar 2015 14:55:21 +0100 Subject: Enable IPv6 by default for travis-ci build * .travis.yml: --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eae990d0ca5..430fde91889 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ before_script: - if [ "$ACEFORTAO" == "1" ]; then echo -e "ace_for_tao=1" >> $ACE_ROOT/bin/MakeProjectCreator/config/default.features; fi - if [ "$CCMLW" == "1" ]; then echo -e "ccm_lw=1" >> $ACE_ROOT/bin/MakeProjectCreator/config/default.features; fi - if [ "$CCMNOEVENT" == "1" ]; then echo -e "ccm_noevent=1" >> $ACE_ROOT/bin/MakeProjectCreator/config/default.features; fi - - echo -e "xerces3=1\nssl=1\n" >> $ACE_ROOT/include/makeinclude/platform_macros.GNU + - echo -e "xerces3=1\nssl=1\nipv6=1\n" >> $ACE_ROOT/include/makeinclude/platform_macros.GNU - echo -e "xerces3=1\nssl=1\n" >> $ACE_ROOT/bin/MakeProjectCreator/config/default.features - echo -e "TAO/tests/Hello/run_test.pl" >> $TAO_ROOT/bin/travis-ci.lst - if [ "$CXX" == "g++" ]; then echo -e "include \$(ACE_ROOT)/include/makeinclude/platform_linux.GNU" >> $ACE_ROOT/include/makeinclude/platform_macros.GNU; fi -- cgit v1.2.1 From 9cd2c61526213e0d20056bcc854bec01b3d2add0 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Mon, 16 Mar 2015 09:30:19 -0500 Subject: Fixed coverity warning 1288509 --- ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp b/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp index 3bc7bd09d13..7453273a511 100644 --- a/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp +++ b/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp @@ -169,11 +169,11 @@ Client::handle_input (ACE_HANDLE handle) ACE_TEXT ("(%t) Client::handle_input handle = %d bytes_read = %d\n"), handle, bytes_read)); - if (bytes_read < 0 && errno == EWOULDBLOCK) + if (bytes_read == -1 && errno == EWOULDBLOCK) { return 0; } - else if (bytes_read == 0) + else if (bytes_read <= 0) { // Closed. return -1; -- cgit v1.2.1 From 06cadd2db3bf8cc34ba70d9e22e025e076cc64da Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Mon, 16 Mar 2015 14:12:04 -0400 Subject: ACE_Addr::set_addr(void*, int) was changed to ACE_Addr::set_addr(const void*, int). All descendant classes have the same change. Fixed multiple-address handling in ACE_INET_Addr and check for alias in INET_Addr_Test if a hostname reverse lookup doesn't match the forward lookup. --- ACE/NEWS | 8 ++++++++ ACE/ace/ATM_Addr.cpp | 5 ++--- ACE/ace/ATM_Addr.h | 2 +- ACE/ace/Addr.cpp | 2 +- ACE/ace/Addr.h | 2 +- ACE/ace/INET_Addr.cpp | 6 ------ ACE/ace/MEM_Addr.cpp | 2 +- ACE/ace/MEM_Addr.h | 2 +- ACE/ace/Netlink_Addr.h | 2 +- ACE/ace/Netlink_Addr.inl | 4 ++-- ACE/ace/SPIPE_Addr.cpp | 6 ++---- ACE/ace/SPIPE_Addr.h | 2 +- ACE/ace/UNIX_Addr.cpp | 6 ++---- ACE/ace/UNIX_Addr.h | 2 +- ACE/tests/INET_Addr_Test.cpp | 13 ++++++++----- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/ACE/NEWS b/ACE/NEWS index 2e2cb9b4628..164955d4c4e 100644 --- a/ACE/NEWS +++ b/ACE/NEWS @@ -19,6 +19,14 @@ USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() methods copy all available addresses related to each name. +. The ACE_Addr::set_addr (void*, int) signature was changed to + ACE_Addr::set_addr (const void*, int). All classes that inherit from + ACE_Addr also have the same change. This affects ACE_ATM_Addr, ACE_Addr, + ACE_INET_Addr, ACE_MEM_Addr, ACE_Netlink_Addr, ACE_SPIPE_Addr, ACE_UNIX_Addr. + Any user-written classes derived from ACE_Addr will also need to change to + match the new signature for virtual method dispatch to continue working + properly in all cases. + USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== diff --git a/ACE/ace/ATM_Addr.cpp b/ACE/ace/ATM_Addr.cpp index 376e1d280ce..afe10cc8f99 100644 --- a/ACE/ace/ATM_Addr.cpp +++ b/ACE/ace/ATM_Addr.cpp @@ -450,7 +450,7 @@ ACE_ATM_Addr::addr_to_string (void) const // Set a pointer to the address. void -ACE_ATM_Addr::set_addr (void *addr, int len) +ACE_ATM_Addr::set_addr (const void *addr, int len) { ACE_TRACE ("ACE_ATM_Addr::set_addr"); @@ -462,8 +462,7 @@ ACE_ATM_Addr::set_addr (void *addr, int len) this->ACE_Addr::base_set (AF_UNSPEC, #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_WS2 */ len); - ACE_OS::memcpy ((void *) &this->atm_addr_, - (void *) addr, len); + ACE_OS::memcpy (&this->atm_addr_, addr, len); } // Compare two addresses for inequality. diff --git a/ACE/ace/ATM_Addr.h b/ACE/ace/ATM_Addr.h index d1e069555ac..8f8aac81d6e 100644 --- a/ACE/ace/ATM_Addr.h +++ b/ACE/ace/ATM_Addr.h @@ -148,7 +148,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the address. - virtual void set_addr (void *, int); + virtual void set_addr (const void *, int); /// Return the selector for network address. u_char get_selector (void) const; diff --git a/ACE/ace/Addr.cpp b/ACE/ace/Addr.cpp index df2d7ce3ff9..dbf1a5c3bd4 100644 --- a/ACE/ace/Addr.cpp +++ b/ACE/ace/Addr.cpp @@ -36,7 +36,7 @@ ACE_Addr::get_addr (void) const } void -ACE_Addr::set_addr (void *, int) +ACE_Addr::set_addr (const void *, int) { } diff --git a/ACE/ace/Addr.h b/ACE/ace/Addr.h index 4dba3934b10..6175fbb27b4 100644 --- a/ACE/ace/Addr.h +++ b/ACE/ace/Addr.h @@ -57,7 +57,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the address. - virtual void set_addr (void *, int len); + virtual void set_addr (const void *, int len); // = Equality/inequality tests /// Check for address equality. diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index f12f3f83ada..cee5e9f2a5d 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -1050,9 +1050,6 @@ int ACE_INET_Addr::set_address (const char *ip_addr, } #endif /* ACE_HAS_IPV6 */ - this->inet_addrs_.clear (); - this->inet_addrs_iter_ = this->inet_addrs_.begin (); - return 0; } /* end if (len == 4) */ #if defined (ACE_HAS_IPV6) @@ -1070,9 +1067,6 @@ int ACE_INET_Addr::set_address (const char *ip_addr, this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); #endif ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); - this->inet_addrs_.clear (); - this->inet_addrs_iter_ = this->inet_addrs_.begin (); - return 0; } /* end len == 16 */ #endif /* ACE_HAS_IPV6 */ diff --git a/ACE/ace/MEM_Addr.cpp b/ACE/ace/MEM_Addr.cpp index d8580715e37..1d06fd02bf4 100644 --- a/ACE/ace/MEM_Addr.cpp +++ b/ACE/ace/MEM_Addr.cpp @@ -115,7 +115,7 @@ ACE_MEM_Addr::get_addr (void) const // Set a pointer to the address. void -ACE_MEM_Addr::set_addr (void *addr, int len) +ACE_MEM_Addr::set_addr (const void *addr, int len) { ACE_TRACE ("ACE_MEM_Addr::set_addr"); diff --git a/ACE/ace/MEM_Addr.h b/ACE/ace/MEM_Addr.h index 54df426b8e8..2944fa9fc7b 100644 --- a/ACE/ace/MEM_Addr.h +++ b/ACE/ace/MEM_Addr.h @@ -76,7 +76,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the address. - virtual void set_addr (void *, int len); + virtual void set_addr (const void *, int len); /// Transform the external ACE_MEM_Addr address into string /// format. diff --git a/ACE/ace/Netlink_Addr.h b/ACE/ace/Netlink_Addr.h index 76fc9d936ff..b9a1e0cc353 100644 --- a/ACE/ace/Netlink_Addr.h +++ b/ACE/ace/Netlink_Addr.h @@ -81,7 +81,7 @@ public: /** * Set a pointer to the address */ - virtual void set_addr (void *, int len= sizeof(sockaddr_nl) ); + virtual void set_addr (const void *, int len= sizeof(sockaddr_nl) ); /// Declare the dynamic allocation hooks. ACE_ALLOC_HOOK_DECLARE; diff --git a/ACE/ace/Netlink_Addr.inl b/ACE/ace/Netlink_Addr.inl index de140c4c094..912f21cd834 100644 --- a/ACE/ace/Netlink_Addr.inl +++ b/ACE/ace/Netlink_Addr.inl @@ -39,8 +39,8 @@ ACE_INLINE int ACE_Netlink_Addr::get_addr_size (void) const } -ACE_INLINE void ACE_Netlink_Addr::set_addr (void *addr, int len){ - ACE_OS::memcpy (&this->nl_,addr,len); +ACE_INLINE void ACE_Netlink_Addr::set_addr (const void *addr, int len) { + ACE_OS::memcpy (&this->nl_, addr, len); } ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/SPIPE_Addr.cpp b/ACE/ace/SPIPE_Addr.cpp index 0928a1c6f12..ef34d66dc24 100644 --- a/ACE/ace/SPIPE_Addr.cpp +++ b/ACE/ace/SPIPE_Addr.cpp @@ -22,14 +22,12 @@ ACE_SPIPE_Addr::dump (void) const // Set a pointer to the address. void -ACE_SPIPE_Addr::set_addr (void *addr, int len) +ACE_SPIPE_Addr::set_addr (const void *addr, int len) { ACE_TRACE ("ACE_SPIPE_Addr::set_addr"); this->ACE_Addr::base_set (AF_SPIPE, len); - ACE_OS::memcpy ((void *) &this->SPIPE_addr_, - (void *) addr, - len); + ACE_OS::memcpy (&this->SPIPE_addr_, addr, len); } // Return the address. diff --git a/ACE/ace/SPIPE_Addr.h b/ACE/ace/SPIPE_Addr.h index 1f25a9a5187..d9e03043378 100644 --- a/ACE/ace/SPIPE_Addr.h +++ b/ACE/ace/SPIPE_Addr.h @@ -55,7 +55,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the underlying network address. - virtual void set_addr (void *addr, int len); + virtual void set_addr (const void *addr, int len); /// Transform the current address into string format. virtual int addr_to_string (ACE_TCHAR *addr, size_t) const; diff --git a/ACE/ace/UNIX_Addr.cpp b/ACE/ace/UNIX_Addr.cpp index b1ade5c20a4..970e4f2743e 100644 --- a/ACE/ace/UNIX_Addr.cpp +++ b/ACE/ace/UNIX_Addr.cpp @@ -14,14 +14,12 @@ ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr) // Set a pointer to the address. void -ACE_UNIX_Addr::set_addr (void *addr, int len) +ACE_UNIX_Addr::set_addr (const void *addr, int len) { ACE_TRACE ("ACE_UNIX_Addr::set_addr"); this->ACE_Addr::base_set (AF_UNIX, len); - ACE_OS::memcpy ((void *) &this->unix_addr_, - (void *) addr, - len); + ACE_OS::memcpy (&this->unix_addr_, addr, len); } // Return a pointer to the underlying address. diff --git a/ACE/ace/UNIX_Addr.h b/ACE/ace/UNIX_Addr.h index 71d55480f2f..02749abf04c 100644 --- a/ACE/ace/UNIX_Addr.h +++ b/ACE/ace/UNIX_Addr.h @@ -63,7 +63,7 @@ public: virtual void *get_addr (void) const; /// Set a pointer to the underlying network address. - virtual void set_addr (void *addr, int len); + virtual void set_addr (const void *addr, int len); /// Transform the current address into string format. virtual int addr_to_string (ACE_TCHAR addr[], size_t) const; diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index f216789a5bc..02551655046 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -271,11 +271,14 @@ int run_main (int, ACE_TCHAR *[]) if (0 != ACE_OS::strcmp (addr.get_host_name (), ipv6_names[i])) { - ACE_ERROR ((LM_WARNING, - ACE_TEXT ("IPv6 name mismatch: %s (%s) != %s\n"), - addr.get_host_name (), - addr.get_host_addr (), - ipv6_names[i])); + // Alias? Check lookup on the reverse. + ACE_INET_Addr alias_check (80, addr.get_host_name ()); + if (addr != alias_check) + ACE_ERROR ((LM_WARNING, + ACE_TEXT ("IPv6 name mismatch: %s (%s) != %s\n"), + addr.get_host_name (), + addr.get_host_addr (), + ipv6_names[i])); } } } -- cgit v1.2.1 From 78184e20fbe56b729019ff3286fc6e515a5f2ff5 Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Mon, 16 Mar 2015 14:16:13 -0400 Subject: Revert "Add ability for ACE_INET_Addr to hold all the addresses assigned to a name" --- ACE/NEWS | 10 -- ACE/ace/INET_Addr.cpp | 193 ++++++++++++--------------------------- ACE/ace/INET_Addr.h | 40 +------- ACE/ace/INET_Addr.inl | 2 +- ACE/ace/Multihomed_INET_Addr.cpp | 81 +++++----------- ACE/tests/INET_Addr_Test.cpp | 60 +----------- 6 files changed, 88 insertions(+), 298 deletions(-) diff --git a/ACE/NEWS b/ACE/NEWS index 2e2cb9b4628..ead8d8db44f 100644 --- a/ACE/NEWS +++ b/ACE/NEWS @@ -8,16 +8,6 @@ USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 supported. Please see tests/Chrono_Test.cpp for more details. -. Allow ACE_INET_Addr to hold all addresses associated with a hostname. The - set of addresses always has a "current" address which is accessed by the - usual "get"-type methods on the class. Two new methods are added to deal - with multiple addresses: - - bool next (void): makes the next available address the "current" one. - Returns false if there are no more addresses. - - void reset (void): resets the iteration mechanism to be able to examine - all of the addresses again. - ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() - methods copy all available addresses related to each name. USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index f12f3f83ada..1c422fdb899 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -152,39 +152,11 @@ ACE_INET_Addr::hash (void) const return this->get_ip_address () + this->get_port_number (); } -bool -ACE_INET_Addr::next (void) -{ - if (this->inet_addrs_.empty () || - this->inet_addrs_iter_ == this->inet_addrs_.end ()) - return false; - - union ip46 next_a = *this->inet_addrs_iter_++; - this->set_addr (&next_a, sizeof (next_a)); - return true; -} - -void -ACE_INET_Addr::reset (void) -{ - this->inet_addrs_iter_ = this->inet_addrs_.begin (); - this->next (); - return; -} - ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); -} - -ACE_INET_Addr & -ACE_INET_Addr::operator= (const ACE_INET_Addr& rhs) -{ - if (this != &rhs) - this->set (rhs); - return *this; + this->reset (); } int @@ -204,8 +176,6 @@ ACE_INET_Addr::set (const ACE_INET_Addr &sa) this->set_type (sa.get_type()); this->set_size (sa.get_size()); - this->inet_addrs_ = sa.inet_addrs_; - this->reset (); } return 0; @@ -296,7 +266,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (address, address_family); } @@ -305,7 +275,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (address, address_family); } @@ -317,7 +287,7 @@ ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) : ACE_Addr (sa.get_type (), sa.get_size()) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (sa); } @@ -384,25 +354,15 @@ ACE_INET_Addr::set (u_short port_number, { if (hp != 0) { + struct sockaddr_in6 v6; + ACE_OS::memset (&v6, 0, sizeof (v6)); + v6.sin6_family = AF_INET6; + (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, + hp->h_addr, + hp->h_length); this->set_type (hp->h_addrtype); - for (size_t i = 0; hp->h_addr_list[i]; ++i) - { - union ip46 next_addr; - struct sockaddr_in6 *next_addr_in6 = &next_addr.in6_; - (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr)); - next_addr_in6->sin6_family = AF_INET6; - next_addr_in6->sin6_port = - encode ? ACE_NTOHS (port_number) : port_number; -#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN - next_addr_in6_->sin6_len = hp->h_length; -#endif - (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr, - hp->h_addr_list[i], - hp->h_length); - this->inet_addrs_.push_back (next_addr); - } - this->reset (); - + this->set_addr (&v6, hp->h_length); + this->set_port_number (port_number, encode); return 0; } } @@ -411,35 +371,16 @@ ACE_INET_Addr::set (u_short port_number, return -1; # else struct addrinfo hints; - struct addrinfo *res = 0, *curr = 0; + struct addrinfo *res = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); - for (curr = res; curr; curr = curr->ai_next) - { - union ip46 next_addr; - if (curr->ai_family == AF_INET6) - { - ACE_OS::memcpy (&next_addr.in6_, - curr->ai_addr, - curr->ai_addrlen); - next_addr.in6_.sin6_port = - encode ? ACE_NTOHS (port_number) : port_number; - } - else - { - ACE_OS::memcpy (&next_addr.in4_, - curr->ai_addr, - curr->ai_addrlen); - next_addr.in4_.sin_port = - encode ? ACE_NTOHS (port_number) : port_number; - } - this->inet_addrs_.push_back (next_addr); - } - this->reset (); + this->set_addr (res->ai_addr, + ACE_Utils::truncate_cast(res->ai_addrlen)); + this->set_port_number (port_number, encode); ::freeaddrinfo (res); return 0; } @@ -465,40 +406,34 @@ ACE_INET_Addr::set (u_short port_number, struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + else { - this->inet_addrs_iter_ = this->inet_addrs_.end (); - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - } - - hostent hentry; - ACE_HOSTENT_DATA buf; - int h_error = 0; // Not the same as errno! + hostent hentry; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! - hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, - buf, &h_error); - if (hp == 0) - { - errno = h_error; - return -1; - } + hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, + buf, &h_error); + if (hp == 0) + errno = h_error; - this->set_type (hp->h_addrtype); - for (size_t i = 0; hp->h_addr_list[i]; ++i) - { - union ip46 next_addr; - struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_; - (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); - next_addr_in->sin_family = AF_INET; - next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number; - (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr, - hp->h_addr_list[i], - hp->h_length); - this->inet_addrs_.push_back (next_addr); + if (hp == 0) + { + return -1; + } + else + { + (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, + hp->h_addr, + hp->h_length); + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + } } - this->reset (); - return 0; } // Helper function to get a port number from a port name. @@ -674,18 +609,17 @@ ACE_INET_Addr::get_addr (void) const } void -ACE_INET_Addr::set_addr (const void *addr, int len) +ACE_INET_Addr::set_addr (void *addr, int len) { this->set_addr (addr, len, 0); } // Set a pointer to the address. void -ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) +ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) { ACE_TRACE ("ACE_INET_Addr::set_addr"); - const struct sockaddr_in *getfamily = - static_cast (addr); + struct sockaddr_in *getfamily = static_cast (addr); if (getfamily->sin_family == AF_INET) { @@ -703,8 +637,7 @@ ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) #if defined (ACE_HAS_IPV6) else if (getfamily->sin_family == AF_INET6) { - const struct sockaddr_in6 *in6 = - static_cast (addr); + struct sockaddr_in6 *in6 = static_cast (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast (&in6->sin6_addr), sizeof (in6->sin6_addr), @@ -720,7 +653,7 @@ ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); this->set (addr, len); } @@ -731,7 +664,7 @@ ACE_INET_Addr::ACE_INET_Addr (u_short port_number, : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -747,7 +680,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, host_name, protocol) == -1) @@ -762,7 +695,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, host_name, protocol) == -1) @@ -779,7 +712,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -794,7 +727,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset_i (); + this->reset (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -1036,23 +969,17 @@ int ACE_INET_Addr::set_address (const char *ip_addr, sizeof (ip6)); return 0; } - else - { - // Build up a 128 bit address. An IPv4-mapped IPv6 address - // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined - // in RFC 1884 */ - ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); - this->inet_addr_.in6_.sin6_addr.s6_addr[10] = - this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; - ACE_OS::memcpy - (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); - } + + // Build up a 128 bit address. An IPv4-mapped IPv6 address + // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined + // in RFC 1884 */ + ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); + this->inet_addr_.in6_.sin6_addr.s6_addr[10] = + this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; + ACE_OS::memcpy + (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); } #endif /* ACE_HAS_IPV6 */ - - this->inet_addrs_.clear (); - this->inet_addrs_iter_ = this->inet_addrs_.begin (); - return 0; } /* end if (len == 4) */ #if defined (ACE_HAS_IPV6) @@ -1070,8 +997,6 @@ int ACE_INET_Addr::set_address (const char *ip_addr, this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); #endif ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); - this->inet_addrs_.clear (); - this->inet_addrs_iter_ = this->inet_addrs_.begin (); return 0; } /* end len == 16 */ diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h index c1a40553754..0c21df7b75b 100644 --- a/ACE/ace/INET_Addr.h +++ b/ACE/ace/INET_Addr.h @@ -19,7 +19,6 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" -#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -28,10 +27,6 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Defines a C++ wrapper facade for the Internet domain address * family format. - * - * ACE_INET_Addr can hold all of the IP addresses assigned to a single name. - * By default it refers only to the first, if there is more than one. The - * next() method can make the others available in turn. */ class ACE_Export ACE_INET_Addr : public ACE_Addr { @@ -113,20 +108,6 @@ public: // These methods are useful after the object has been constructed. - /// Assignment. In a more well-ordered world, member-wise assignment would - /// work fine. However, because of the class design feature that all of the - /// acceptor/connector-type classes that can be used in the - /// Acceptor-Connector framework take ACE_Addr objects instead of the - /// addressing class matching the family in use. The mechanism used to - /// enable this substitution to the more-appropriate class is - /// ACE_sap_any_cast, which casts the ACE_Addr to the more-specific class. - /// In this case, casting an ACE_Addr to ACE_INET_Addr then copying it. - /// Since adding multiple address support to ACE_INET_Addr, that cast-copy - /// operation ends up, in the member-wise case, copying a bogus vector - /// and doing lots of random damage. Thus, this operator is used to make - /// life ordered in this common scenario. - ACE_INET_Addr & operator= (const ACE_INET_Addr &rhs); - /// Initializes from another ACE_INET_Addr. int set (const ACE_INET_Addr &); @@ -208,14 +189,14 @@ public: int get_addr_size(void) const; /// Set a pointer to the address. - virtual void set_addr (const void *, int len); + virtual void set_addr (void *, int len); /// Set a pointer to the address. - virtual void set_addr (const void *, int len, int map); + virtual void set_addr (void *, int len, int map); /** * Transform the current ACE_INET_Addr address into string format. - * If @a ipaddr_format is true this produces "ip-number:port-number" + * If @a ipaddr_format is ttrue this produces "ip-number:port-number" * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false * this produces "ip-name:port-number" (e.g., * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the @@ -366,13 +347,6 @@ public: /// Computes and returns hash value. virtual u_long hash (void) const; - /// If there is another address to examine, move to it and return true; - /// else return false. - bool next (void); - - /// Reset the set of address so they can be scanned again using next(). - void reset (void); - /// Dump the state of an object. void dump (void) const; @@ -390,22 +364,18 @@ private: int determine_type (void) const; /// Initialize underlying inet_addr_ to default values - void reset_i (void); + void reset (void); /// Underlying representation. /// This union uses the knowledge that the two structures share the /// first member, sa_family (as all sockaddr structures do). - union ip46 + union { sockaddr_in in4_; #if defined (ACE_HAS_IPV6) sockaddr_in6 in6_; #endif /* ACE_HAS_IPV6 */ } inet_addr_; - // If there is more than one address assigned to a given name, this - // holds all of them; one is always copied to inet_addr_. - std::vector inet_addrs_; - std::vector::iterator inet_addrs_iter_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/INET_Addr.inl b/ACE/ace/INET_Addr.inl index 2532bb9cb6f..6cc14c97558 100644 --- a/ACE/ace/INET_Addr.inl +++ b/ACE/ace/INET_Addr.inl @@ -7,7 +7,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void -ACE_INET_Addr::reset_i (void) +ACE_INET_Addr::reset (void) { ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->get_type() == AF_INET) diff --git a/ACE/ace/Multihomed_INET_Addr.cpp b/ACE/ace/Multihomed_INET_Addr.cpp index 1acc40c1053..a734beb1ae2 100644 --- a/ACE/ace/Multihomed_INET_Addr.cpp +++ b/ACE/ace/Multihomed_INET_Addr.cpp @@ -243,40 +243,21 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs, size_t size) const { - if (size == 0) - return; - // Copy primary address(es) to the first slot(s) of the user-supplied array - ACE_INET_Addr me (*this); - size_t i = 0; - for (i = 0; i < size; ++i) - { - sockaddr_in *in4 = reinterpret_cast (me.get_addr ()); - if (in4->sin_family == AF_INET) - { - addrs[i] = *in4; - ++i; - } - if (!me.next ()) - break; - } + // Copy primary address to the first slot of the user-supplied array + if (size > 0) { + addrs[0] = *reinterpret_cast (this->get_addr ()); + } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - for (size_t j = 0; j < this->secondaries_.size (); ++j) - { - ACE_INET_Addr copy (this->secondaries_[j]); - for (; i < size; ++i) - { - sockaddr_in *in4 = reinterpret_cast (copy.get_addr ()); - if (in4->sin_family == AF_INET) - { - addrs[i] = *in4; - ++i; - } - if (!copy.next ()) - break; - } - } + + size_t top = size - 1 < this->secondaries_.size() ? + size - 1 : this->secondaries_.size(); + + for (size_t i = 0; i < top; ++i) { + addrs[i+1] = + *reinterpret_cast (this->secondaries_[i].get_addr()); + } } #if defined (ACE_HAS_IPV6) @@ -284,40 +265,22 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs, size_t size) const { - if (size == 0) - return; - // Copy primary address(es) to the first slot(s) of the user-supplied array - ACE_INET_Addr me (*this); - size_t i = 0; - for (i = 0; i < size; ++i) + // Copy primary address to the first slot of the user-supplied array + if (size > 0) { - sockaddr_in6 *in6 = reinterpret_cast (me.get_addr ()); - if (in6->sin6_family == AF_INET6) - { - addrs[i] = *in6; - ++i; - } - if (!me.next ()) - break; + addrs[0] = *reinterpret_cast (this->get_addr ()); } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - for (size_t j = 0; j < this->secondaries_.size (); ++j) + size_t top = + size - 1 < this->secondaries_.size() ? + size - 1 : this->secondaries_.size(); + + for (size_t i = 0; i < top; ++i) { - ACE_INET_Addr copy (this->secondaries_[j]); - for (; i < size; ++i) - { - sockaddr_in6 *in6 = - reinterpret_cast (copy.get_addr ()); - if (in6->sin6_family == AF_INET6) - { - addrs[i] = *in6; - ++i; - } - if (!copy.next ()) - break; - } + addrs[i+1] = + *reinterpret_cast (this->secondaries_[i].get_addr()); } } #endif /* ACE_HAS_IPV6 */ diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index f216789a5bc..4743b2894f3 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -20,7 +20,7 @@ // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. -static int check_type_consistency (const ACE_INET_Addr &addr) +int check_type_consistency (const ACE_INET_Addr &addr) { int family = -1; @@ -49,52 +49,6 @@ static int check_type_consistency (const ACE_INET_Addr &addr) return 0; } -static bool test_multiple (void) -{ - - bool success = true; - - // Check the behavior when there are multiple addresses assigned to a name. - // The NTP pool should always return multiples, though always different. - ACE_INET_Addr ntp; - if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1) - { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org"))); - return false; - } - size_t count = 0; - ACE_TCHAR addr_string[256]; - do - { - ++count; // If lookup succeeded, there's at least one - ntp.addr_to_string (addr_string, sizeof (addr_string)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string)); - } - while (ntp.next ()); - success = count > 1; - -#if defined (ACE_HAS_IPV6) - ACE_INET_Addr ntp6; - if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1) - { - ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org"))); - return false; - } - count = 0; - do - { - ++count; // If lookup succeeded, there's at least one - ntp6.addr_to_string (addr_string, sizeof (addr_string)); - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string)); - } - while (ntp6.next ()); - if (count <= 1) - success = false; -#endif /* ACE_HAS_IPV6 */ - - return success; -} - struct Address { const char* name; bool loopback; @@ -319,18 +273,6 @@ int run_main (int, ACE_TCHAR *[]) status = 1; } - if (!test_multiple ()) - status = 1; - - ACE_INET_Addr a1 (80, "127.0.0.1"); - ACE_INET_Addr a2 = a1; - if (a1 != a2) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Address equality check failed after assignment\n"))); - status = 1; - } - ACE_END_TEST; return status; -- cgit v1.2.1 From b1ccc1215ca8572732f35f856891e03d1fdc0d3a Mon Sep 17 00:00:00 2001 From: Steve Huston Date: Mon, 16 Mar 2015 14:17:53 -0400 Subject: Revert "Revert "Add ability for ACE_INET_Addr to hold all the addresses assigned..." --- ACE/NEWS | 10 ++ ACE/ace/INET_Addr.cpp | 193 +++++++++++++++++++++++++++------------ ACE/ace/INET_Addr.h | 40 +++++++- ACE/ace/INET_Addr.inl | 2 +- ACE/ace/Multihomed_INET_Addr.cpp | 81 +++++++++++----- ACE/tests/INET_Addr_Test.cpp | 60 +++++++++++- 6 files changed, 298 insertions(+), 88 deletions(-) diff --git a/ACE/NEWS b/ACE/NEWS index ead8d8db44f..2e2cb9b4628 100644 --- a/ACE/NEWS +++ b/ACE/NEWS @@ -8,6 +8,16 @@ USER VISIBLE CHANGES BETWEEN ACE-6.3.1 and ACE-6.3.2 supported. Please see tests/Chrono_Test.cpp for more details. +. Allow ACE_INET_Addr to hold all addresses associated with a hostname. The + set of addresses always has a "current" address which is accessed by the + usual "get"-type methods on the class. Two new methods are added to deal + with multiple addresses: + - bool next (void): makes the next available address the "current" one. + Returns false if there are no more addresses. + - void reset (void): resets the iteration mechanism to be able to examine + all of the addresses again. + ACE_Multihomed_INET_Addr has also been enhanced so that the get_addresses() + methods copy all available addresses related to each name. USER VISIBLE CHANGES BETWEEN ACE-6.3.0 and ACE-6.3.1 ==================================================== diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 1c422fdb899..f12f3f83ada 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -152,11 +152,39 @@ ACE_INET_Addr::hash (void) const return this->get_ip_address () + this->get_port_number (); } +bool +ACE_INET_Addr::next (void) +{ + if (this->inet_addrs_.empty () || + this->inet_addrs_iter_ == this->inet_addrs_.end ()) + return false; + + union ip46 next_a = *this->inet_addrs_iter_++; + this->set_addr (&next_a, sizeof (next_a)); + return true; +} + +void +ACE_INET_Addr::reset (void) +{ + this->inet_addrs_iter_ = this->inet_addrs_.begin (); + this->next (); + return; +} + ACE_INET_Addr::ACE_INET_Addr (void) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { // ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); +} + +ACE_INET_Addr & +ACE_INET_Addr::operator= (const ACE_INET_Addr& rhs) +{ + if (this != &rhs) + this->set (rhs); + return *this; } int @@ -176,6 +204,8 @@ ACE_INET_Addr::set (const ACE_INET_Addr &sa) this->set_type (sa.get_type()); this->set_size (sa.get_size()); + this->inet_addrs_ = sa.inet_addrs_; + this->reset (); } return 0; @@ -266,7 +296,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (address, address_family); } @@ -275,7 +305,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t address[], int address_family) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (address, address_family); } @@ -287,7 +317,7 @@ ACE_INET_Addr::ACE_INET_Addr (const ACE_INET_Addr &sa) : ACE_Addr (sa.get_type (), sa.get_size()) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (sa); } @@ -354,15 +384,25 @@ ACE_INET_Addr::set (u_short port_number, { if (hp != 0) { - struct sockaddr_in6 v6; - ACE_OS::memset (&v6, 0, sizeof (v6)); - v6.sin6_family = AF_INET6; - (void) ACE_OS::memcpy ((void *) &v6.sin6_addr, - hp->h_addr, - hp->h_length); this->set_type (hp->h_addrtype); - this->set_addr (&v6, hp->h_length); - this->set_port_number (port_number, encode); + for (size_t i = 0; hp->h_addr_list[i]; ++i) + { + union ip46 next_addr; + struct sockaddr_in6 *next_addr_in6 = &next_addr.in6_; + (void) ACE_OS::memset (&next_addr, 0, sizeof (next_addr)); + next_addr_in6->sin6_family = AF_INET6; + next_addr_in6->sin6_port = + encode ? ACE_NTOHS (port_number) : port_number; +#ifdef ACE_HAS_SOCKADDR_IN6_SIN6_LEN + next_addr_in6_->sin6_len = hp->h_length; +#endif + (void) ACE_OS::memcpy ((void *) &next_addr_in6->sin6_addr, + hp->h_addr_list[i], + hp->h_length); + this->inet_addrs_.push_back (next_addr); + } + this->reset (); + return 0; } } @@ -371,16 +411,35 @@ ACE_INET_Addr::set (u_short port_number, return -1; # else struct addrinfo hints; - struct addrinfo *res = 0; + struct addrinfo *res = 0, *curr = 0; int error = 0; ACE_OS::memset (&hints, 0, sizeof (hints)); hints.ai_family = AF_INET6; if ((error = ::getaddrinfo (host_name, 0, &hints, &res)) == 0) { this->set_type (res->ai_family); - this->set_addr (res->ai_addr, - ACE_Utils::truncate_cast(res->ai_addrlen)); - this->set_port_number (port_number, encode); + for (curr = res; curr; curr = curr->ai_next) + { + union ip46 next_addr; + if (curr->ai_family == AF_INET6) + { + ACE_OS::memcpy (&next_addr.in6_, + curr->ai_addr, + curr->ai_addrlen); + next_addr.in6_.sin6_port = + encode ? ACE_NTOHS (port_number) : port_number; + } + else + { + ACE_OS::memcpy (&next_addr.in4_, + curr->ai_addr, + curr->ai_addrlen); + next_addr.in4_.sin_port = + encode ? ACE_NTOHS (port_number) : port_number; + } + this->inet_addrs_.push_back (next_addr); + } + this->reset (); ::freeaddrinfo (res); return 0; } @@ -406,34 +465,40 @@ ACE_INET_Addr::set (u_short port_number, struct in_addr addrv4; if (ACE_OS::inet_aton (host_name, &addrv4) == 1) - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - else { - hostent hentry; - ACE_HOSTENT_DATA buf; - int h_error = 0; // Not the same as errno! + this->inet_addrs_iter_ = this->inet_addrs_.end (); + return this->set (port_number, + encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, + encode); + } - hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, - buf, &h_error); - if (hp == 0) - errno = h_error; + hostent hentry; + ACE_HOSTENT_DATA buf; + int h_error = 0; // Not the same as errno! - if (hp == 0) - { - return -1; - } - else - { - (void) ACE_OS::memcpy ((void *) &addrv4.s_addr, - hp->h_addr, - hp->h_length); - return this->set (port_number, - encode ? ACE_NTOHL (addrv4.s_addr) : addrv4.s_addr, - encode); - } + hostent *hp = ACE_OS::gethostbyname_r (host_name, &hentry, + buf, &h_error); + if (hp == 0) + { + errno = h_error; + return -1; + } + + this->set_type (hp->h_addrtype); + for (size_t i = 0; hp->h_addr_list[i]; ++i) + { + union ip46 next_addr; + struct sockaddr_in *next_addr_in = (struct sockaddr_in *)&next_addr.in4_; + (void) ACE_OS::memset (&next_addr, sizeof (next_addr), 0); + next_addr_in->sin_family = AF_INET; + next_addr_in->sin_port = encode ? ACE_NTOHS (port_number) : port_number; + (void) ACE_OS::memcpy ((void *) &next_addr_in->sin_addr, + hp->h_addr_list[i], + hp->h_length); + this->inet_addrs_.push_back (next_addr); } + this->reset (); + return 0; } // Helper function to get a port number from a port name. @@ -609,17 +674,18 @@ ACE_INET_Addr::get_addr (void) const } void -ACE_INET_Addr::set_addr (void *addr, int len) +ACE_INET_Addr::set_addr (const void *addr, int len) { this->set_addr (addr, len, 0); } // Set a pointer to the address. void -ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) +ACE_INET_Addr::set_addr (const void *addr, int /* len */, int map) { ACE_TRACE ("ACE_INET_Addr::set_addr"); - struct sockaddr_in *getfamily = static_cast (addr); + const struct sockaddr_in *getfamily = + static_cast (addr); if (getfamily->sin_family == AF_INET) { @@ -637,7 +703,8 @@ ACE_INET_Addr::set_addr (void *addr, int /* len */, int map) #if defined (ACE_HAS_IPV6) else if (getfamily->sin_family == AF_INET6) { - struct sockaddr_in6 *in6 = static_cast (addr); + const struct sockaddr_in6 *in6 = + static_cast (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast (&in6->sin6_addr), sizeof (in6->sin6_addr), @@ -653,7 +720,7 @@ ACE_INET_Addr::ACE_INET_Addr (const sockaddr_in *addr, int len) : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); this->set (addr, len); } @@ -664,7 +731,7 @@ ACE_INET_Addr::ACE_INET_Addr (u_short port_number, : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_number, inet_address) == -1) ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), @@ -680,7 +747,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, host_name, protocol) == -1) @@ -695,7 +762,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, host_name, protocol) == -1) @@ -712,7 +779,7 @@ ACE_INET_Addr::ACE_INET_Addr (const char port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -727,7 +794,7 @@ ACE_INET_Addr::ACE_INET_Addr (const wchar_t port_name[], : ACE_Addr (determine_type (), sizeof (inet_addr_)) { ACE_TRACE ("ACE_INET_Addr::ACE_INET_Addr"); - this->reset (); + this->reset_i (); if (this->set (port_name, ACE_HTONL (inet_address), protocol) == -1) @@ -969,17 +1036,23 @@ int ACE_INET_Addr::set_address (const char *ip_addr, sizeof (ip6)); return 0; } - - // Build up a 128 bit address. An IPv4-mapped IPv6 address - // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined - // in RFC 1884 */ - ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); - this->inet_addr_.in6_.sin6_addr.s6_addr[10] = - this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; - ACE_OS::memcpy - (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); + else + { + // Build up a 128 bit address. An IPv4-mapped IPv6 address + // is defined as 0:0:0:0:0:ffff:IPv4_address. This is defined + // in RFC 1884 */ + ACE_OS::memset (&this->inet_addr_.in6_.sin6_addr, 0, 16); + this->inet_addr_.in6_.sin6_addr.s6_addr[10] = + this->inet_addr_.in6_.sin6_addr.s6_addr[11] = 0xff; + ACE_OS::memcpy + (&this->inet_addr_.in6_.sin6_addr.s6_addr[12], &ip4, 4); + } } #endif /* ACE_HAS_IPV6 */ + + this->inet_addrs_.clear (); + this->inet_addrs_iter_ = this->inet_addrs_.begin (); + return 0; } /* end if (len == 4) */ #if defined (ACE_HAS_IPV6) @@ -997,6 +1070,8 @@ int ACE_INET_Addr::set_address (const char *ip_addr, this->inet_addr_.in6_.sin6_len = sizeof (this->inet_addr_.in6_); #endif ACE_OS::memcpy (&this->inet_addr_.in6_.sin6_addr, ip_addr, len); + this->inet_addrs_.clear (); + this->inet_addrs_iter_ = this->inet_addrs_.begin (); return 0; } /* end len == 16 */ diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h index 0c21df7b75b..c1a40553754 100644 --- a/ACE/ace/INET_Addr.h +++ b/ACE/ace/INET_Addr.h @@ -19,6 +19,7 @@ #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Addr.h" +#include ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -27,6 +28,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * * @brief Defines a C++ wrapper facade for the Internet domain address * family format. + * + * ACE_INET_Addr can hold all of the IP addresses assigned to a single name. + * By default it refers only to the first, if there is more than one. The + * next() method can make the others available in turn. */ class ACE_Export ACE_INET_Addr : public ACE_Addr { @@ -108,6 +113,20 @@ public: // These methods are useful after the object has been constructed. + /// Assignment. In a more well-ordered world, member-wise assignment would + /// work fine. However, because of the class design feature that all of the + /// acceptor/connector-type classes that can be used in the + /// Acceptor-Connector framework take ACE_Addr objects instead of the + /// addressing class matching the family in use. The mechanism used to + /// enable this substitution to the more-appropriate class is + /// ACE_sap_any_cast, which casts the ACE_Addr to the more-specific class. + /// In this case, casting an ACE_Addr to ACE_INET_Addr then copying it. + /// Since adding multiple address support to ACE_INET_Addr, that cast-copy + /// operation ends up, in the member-wise case, copying a bogus vector + /// and doing lots of random damage. Thus, this operator is used to make + /// life ordered in this common scenario. + ACE_INET_Addr & operator= (const ACE_INET_Addr &rhs); + /// Initializes from another ACE_INET_Addr. int set (const ACE_INET_Addr &); @@ -189,14 +208,14 @@ public: int get_addr_size(void) const; /// Set a pointer to the address. - virtual void set_addr (void *, int len); + virtual void set_addr (const void *, int len); /// Set a pointer to the address. - virtual void set_addr (void *, int len, int map); + virtual void set_addr (const void *, int len, int map); /** * Transform the current ACE_INET_Addr address into string format. - * If @a ipaddr_format is ttrue this produces "ip-number:port-number" + * If @a ipaddr_format is true this produces "ip-number:port-number" * (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false * this produces "ip-name:port-number" (e.g., * "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the @@ -347,6 +366,13 @@ public: /// Computes and returns hash value. virtual u_long hash (void) const; + /// If there is another address to examine, move to it and return true; + /// else return false. + bool next (void); + + /// Reset the set of address so they can be scanned again using next(). + void reset (void); + /// Dump the state of an object. void dump (void) const; @@ -364,18 +390,22 @@ private: int determine_type (void) const; /// Initialize underlying inet_addr_ to default values - void reset (void); + void reset_i (void); /// Underlying representation. /// This union uses the knowledge that the two structures share the /// first member, sa_family (as all sockaddr structures do). - union + union ip46 { sockaddr_in in4_; #if defined (ACE_HAS_IPV6) sockaddr_in6 in6_; #endif /* ACE_HAS_IPV6 */ } inet_addr_; + // If there is more than one address assigned to a given name, this + // holds all of them; one is always copied to inet_addr_. + std::vector inet_addrs_; + std::vector::iterator inet_addrs_iter_; }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/INET_Addr.inl b/ACE/ace/INET_Addr.inl index 6cc14c97558..2532bb9cb6f 100644 --- a/ACE/ace/INET_Addr.inl +++ b/ACE/ace/INET_Addr.inl @@ -7,7 +7,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void -ACE_INET_Addr::reset (void) +ACE_INET_Addr::reset_i (void) { ACE_OS::memset (&this->inet_addr_, 0, sizeof (this->inet_addr_)); if (this->get_type() == AF_INET) diff --git a/ACE/ace/Multihomed_INET_Addr.cpp b/ACE/ace/Multihomed_INET_Addr.cpp index a734beb1ae2..1acc40c1053 100644 --- a/ACE/ace/Multihomed_INET_Addr.cpp +++ b/ACE/ace/Multihomed_INET_Addr.cpp @@ -243,21 +243,40 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in *addrs, size_t size) const { - // Copy primary address to the first slot of the user-supplied array - if (size > 0) { - addrs[0] = *reinterpret_cast (this->get_addr ()); - } + if (size == 0) + return; + // Copy primary address(es) to the first slot(s) of the user-supplied array + ACE_INET_Addr me (*this); + size_t i = 0; + for (i = 0; i < size; ++i) + { + sockaddr_in *in4 = reinterpret_cast (me.get_addr ()); + if (in4->sin_family == AF_INET) + { + addrs[i] = *in4; + ++i; + } + if (!me.next ()) + break; + } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - - size_t top = size - 1 < this->secondaries_.size() ? - size - 1 : this->secondaries_.size(); - - for (size_t i = 0; i < top; ++i) { - addrs[i+1] = - *reinterpret_cast (this->secondaries_[i].get_addr()); - } + for (size_t j = 0; j < this->secondaries_.size (); ++j) + { + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in *in4 = reinterpret_cast (copy.get_addr ()); + if (in4->sin_family == AF_INET) + { + addrs[i] = *in4; + ++i; + } + if (!copy.next ()) + break; + } + } } #if defined (ACE_HAS_IPV6) @@ -265,22 +284,40 @@ void ACE_Multihomed_INET_Addr::get_addresses(sockaddr_in6 *addrs, size_t size) const { - // Copy primary address to the first slot of the user-supplied array - if (size > 0) + if (size == 0) + return; + // Copy primary address(es) to the first slot(s) of the user-supplied array + ACE_INET_Addr me (*this); + size_t i = 0; + for (i = 0; i < size; ++i) { - addrs[0] = *reinterpret_cast (this->get_addr ()); + sockaddr_in6 *in6 = reinterpret_cast (me.get_addr ()); + if (in6->sin6_family == AF_INET6) + { + addrs[i] = *in6; + ++i; + } + if (!me.next ()) + break; } // Copy secondary addresses to remaining slots of the user-supplied // array. Secondary address [i] is copied to slot [i+1] - size_t top = - size - 1 < this->secondaries_.size() ? - size - 1 : this->secondaries_.size(); - - for (size_t i = 0; i < top; ++i) + for (size_t j = 0; j < this->secondaries_.size (); ++j) { - addrs[i+1] = - *reinterpret_cast (this->secondaries_[i].get_addr()); + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in6 *in6 = + reinterpret_cast (copy.get_addr ()); + if (in6->sin6_family == AF_INET6) + { + addrs[i] = *in6; + ++i; + } + if (!copy.next ()) + break; + } } } #endif /* ACE_HAS_IPV6 */ diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index 4743b2894f3..f216789a5bc 100644 --- a/ACE/tests/INET_Addr_Test.cpp +++ b/ACE/tests/INET_Addr_Test.cpp @@ -20,7 +20,7 @@ // Make sure that ACE_Addr::addr_type_ is the same // as the family of the inet_addr_. -int check_type_consistency (const ACE_INET_Addr &addr) +static int check_type_consistency (const ACE_INET_Addr &addr) { int family = -1; @@ -49,6 +49,52 @@ int check_type_consistency (const ACE_INET_Addr &addr) return 0; } +static bool test_multiple (void) +{ + + bool success = true; + + // Check the behavior when there are multiple addresses assigned to a name. + // The NTP pool should always return multiples, though always different. + ACE_INET_Addr ntp; + if (ntp.set (123, ACE_TEXT ("pool.ntp.org")) == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("pool.ntp.org"))); + return false; + } + size_t count = 0; + ACE_TCHAR addr_string[256]; + do + { + ++count; // If lookup succeeded, there's at least one + ntp.addr_to_string (addr_string, sizeof (addr_string)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv4 %B: %s\n"), count, addr_string)); + } + while (ntp.next ()); + success = count > 1; + +#if defined (ACE_HAS_IPV6) + ACE_INET_Addr ntp6; + if (ntp6.set (123, ACE_TEXT ("2.pool.ntp.org"), 1, AF_INET6) == -1) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("2.pool.ntp.org"))); + return false; + } + count = 0; + do + { + ++count; // If lookup succeeded, there's at least one + ntp6.addr_to_string (addr_string, sizeof (addr_string)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 %B: %s\n"), count, addr_string)); + } + while (ntp6.next ()); + if (count <= 1) + success = false; +#endif /* ACE_HAS_IPV6 */ + + return success; +} + struct Address { const char* name; bool loopback; @@ -273,6 +319,18 @@ int run_main (int, ACE_TCHAR *[]) status = 1; } + if (!test_multiple ()) + status = 1; + + ACE_INET_Addr a1 (80, "127.0.0.1"); + ACE_INET_Addr a2 = a1; + if (a1 != a2) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Address equality check failed after assignment\n"))); + status = 1; + } + ACE_END_TEST; return status; -- cgit v1.2.1 From 57c6f367640694b185db7f836396319730653334 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 17 Mar 2015 08:58:50 +0100 Subject: Layout changes --- TAO/orbsvcs/tests/ImplRepo/manual_start/server.cpp | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/TAO/orbsvcs/tests/ImplRepo/manual_start/server.cpp b/TAO/orbsvcs/tests/ImplRepo/manual_start/server.cpp index 1b530343a03..c8bc7e309a6 100755 --- a/TAO/orbsvcs/tests/ImplRepo/manual_start/server.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/manual_start/server.cpp @@ -64,34 +64,34 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) PortableServer::POAManager_var mgr = root_poa->the_POAManager (); PortableServer::POA_var test_poa = createPOA (root_poa.in(), poa_name ); - Test_i *impl = new Test_i (); - PortableServer::Servant_var test_servant = impl; - - PortableServer::ObjectId_var object_id = - PortableServer::string_to_ObjectId ("test_object"); - - test_poa->activate_object_with_id (object_id.in(), test_servant.in()); - - obj = test_poa->id_to_reference (object_id.in ()); - CORBA::String_var test_ior = orb->object_to_string (obj.in ()); - FILE *f = ACE_OS::fopen (ior_file_name, ACE_TEXT ("w")); - ACE_OS::fprintf (f, "%s", test_ior.in ()); - ACE_OS::fclose (f); - - mgr->activate(); - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) Started Server <%s>\n"), - poa_name)); - - ACE_Time_Value tv (1,0); - orb->run (tv); - root_poa->destroy(1,1); - orb->destroy(); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) Server <%s> orb destroyed\n"), - poa_name)); - } + Test_i *impl = new Test_i (); + PortableServer::Servant_var test_servant = impl; + + PortableServer::ObjectId_var object_id = + PortableServer::string_to_ObjectId ("test_object"); + + test_poa->activate_object_with_id (object_id.in(), test_servant.in()); + + obj = test_poa->id_to_reference (object_id.in ()); + CORBA::String_var test_ior = orb->object_to_string (obj.in ()); + FILE *f = ACE_OS::fopen (ior_file_name, ACE_TEXT ("w")); + ACE_OS::fprintf (f, "%s", test_ior.in ()); + ACE_OS::fclose (f); + + mgr->activate(); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) Started Server <%s>\n"), + poa_name)); + + ACE_Time_Value tv (1,0); + orb->run (tv); + root_poa->destroy(1,1); + orb->destroy(); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) Server <%s> orb destroyed\n"), + poa_name)); + } catch(const CORBA::Exception& ex) { ex._tao_print_exception (ACE_TEXT ("Server main()")); return 1; -- cgit v1.2.1 From d76367da7959e9eeeff67b308052d5008cd74d2b Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 17 Mar 2015 08:59:03 +0100 Subject: Removed empty line * TAO/tao/DynamicInterface/Dynamic_Implementation.cpp: --- TAO/tao/DynamicInterface/Dynamic_Implementation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp b/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp index f61b145bf7a..982ab13ebb7 100644 --- a/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp +++ b/TAO/tao/DynamicInterface/Dynamic_Implementation.cpp @@ -12,7 +12,6 @@ #include "ace/Dynamic_Service.h" #include "ace/OS_NS_string.h" - TAO_BEGIN_VERSIONED_NAMESPACE_DECL CORBA::Boolean -- cgit v1.2.1 From 19903115ff9671d44ada6fdd75a7fdd555161618 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 17 Mar 2015 09:00:00 +0100 Subject: Removed not needed return --- TAO/tao/Object.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp index 417e3d72eb3..3e73ac25c1c 100644 --- a/TAO/tao/Object.cpp +++ b/TAO/tao/Object.cpp @@ -837,7 +837,6 @@ CORBA::Object::tao_object_initialize (CORBA::Object *obj) // Transfer ownership to the CORBA::Object (void) safe_objdata.release (); - return; } CORBA::Boolean -- cgit v1.2.1