diff options
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/NEWS | 18 | ||||
-rw-r--r-- | ACE/ace/ACE.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/ATM_Addr.cpp | 5 | ||||
-rw-r--r-- | ACE/ace/ATM_Addr.h | 2 | ||||
-rw-r--r-- | ACE/ace/Addr.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/Addr.h | 2 | ||||
-rw-r--r-- | ACE/ace/Dev_Poll_Reactor.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/INET_Addr.cpp | 189 | ||||
-rw-r--r-- | ACE/ace/INET_Addr.h | 40 | ||||
-rw-r--r-- | ACE/ace/INET_Addr.inl | 2 | ||||
-rw-r--r-- | ACE/ace/MEM_Addr.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/MEM_Addr.h | 2 | ||||
-rw-r--r-- | ACE/ace/Multihomed_INET_Addr.cpp | 81 | ||||
-rw-r--r-- | ACE/ace/Netlink_Addr.h | 2 | ||||
-rw-r--r-- | ACE/ace/Netlink_Addr.inl | 4 | ||||
-rw-r--r-- | ACE/ace/SPIPE_Addr.cpp | 6 | ||||
-rw-r--r-- | ACE/ace/SPIPE_Addr.h | 2 | ||||
-rw-r--r-- | ACE/ace/UNIX_Addr.cpp | 6 | ||||
-rw-r--r-- | ACE/ace/UNIX_Addr.h | 2 | ||||
-rw-r--r-- | ACE/bin/MakeProjectCreator/modules/GNUACEWorkspaceCreator.pm | 2 | ||||
-rw-r--r-- | ACE/bin/valgrind.supp | 7 | ||||
-rw-r--r-- | ACE/docs/bczar/bczar.html | 2 | ||||
-rw-r--r-- | ACE/tests/.gitignore | 1 | ||||
-rw-r--r-- | ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp | 2 | ||||
-rw-r--r-- | ACE/tests/INET_Addr_Test.cpp | 73 |
25 files changed, 338 insertions, 120 deletions
@@ -8,6 +8,24 @@ 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. + +. 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/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 <timeout> for the blocking to subside. int const rtn = ACE::handle_write_ready (handle, timeout); 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/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. diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 1c422fdb899..cee5e9f2a5d 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<int>(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<struct sockaddr_in *> (addr); + const struct sockaddr_in *getfamily = + static_cast<const struct sockaddr_in *> (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<struct sockaddr_in6*> (addr); + const struct sockaddr_in6 *in6 = + static_cast<const struct sockaddr_in6*> (addr); this->set_port_number (in6->sin6_port, 0); this->set_address (reinterpret_cast<const char*> (&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,20 @@ 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 */ + return 0; } /* end if (len == 4) */ #if defined (ACE_HAS_IPV6) @@ -997,7 +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); - return 0; } /* end len == 16 */ #endif /* ACE_HAS_IPV6 */ 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 <vector> 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<union ip46> inet_addrs_; + std::vector<union ip46>::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/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/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<sockaddr_in*> (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<sockaddr_in*> (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<sockaddr_in*> (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<sockaddr_in*> (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<sockaddr_in6*> (this->get_addr ()); + sockaddr_in6 *in6 = reinterpret_cast<sockaddr_in6*> (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<sockaddr_in6*> (this->secondaries_[i].get_addr()); + ACE_INET_Addr copy (this->secondaries_[j]); + for (; i < size; ++i) + { + sockaddr_in6 *in6 = + reinterpret_cast<sockaddr_in6*> (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/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/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); } 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 @@ -35,6 +35,13 @@ } { + <Suppress all the conditional jumps in grep> + Memcheck:Cond + ... + obj:*/bin/grep +} + +{ <Suppress all the leaks in ps> Memcheck:Leak ... 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 @@ </ul> If you want to perform a full build with qt support, than run: <ul> - <li><code>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</code></li> + <li><code>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</code></li> </ul> For some optional i686 packages run <ul> 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/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp b/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp index 04c169234a8..7453273a511 100644 --- a/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp +++ b/ACE/tests/Dev_Poll_Reactor_Echo_Test.cpp @@ -173,7 +173,7 @@ Client::handle_input (ACE_HANDLE handle) { return 0; } - else if (bytes_read == 0) + else if (bytes_read <= 0) { // Closed. return -1; diff --git a/ACE/tests/INET_Addr_Test.cpp b/ACE/tests/INET_Addr_Test.cpp index 4743b2894f3..02551655046 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; @@ -225,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])); } } } @@ -273,6 +322,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; |