diff options
author | Jose <jose@zeroc.com> | 2018-02-08 17:23:26 +0100 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2018-02-08 17:23:26 +0100 |
commit | 41a4ea50bba42cd4585244f5a8e3ccbc6c20da4c (patch) | |
tree | 92eda1d6156d91d4bfce18f8fc06820af1e401ff /cpp/src | |
parent | Remove old files (diff) | |
parent | Fixed matlab check for testing (diff) | |
download | ice-41a4ea50bba42cd4585244f5a8e3ccbc6c20da4c.tar.bz2 ice-41a4ea50bba42cd4585244f5a8e3ccbc6c20da4c.tar.xz ice-41a4ea50bba42cd4585244f5a8e3ccbc6c20da4c.zip |
Merge branch '3.7' of github.com:zeroc-ice/ice into 3.7
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Glacier2/SessionRouterI.cpp | 7 | ||||
-rwxr-xr-x | cpp/src/Ice/Network.cpp | 64 |
2 files changed, 51 insertions, 20 deletions
diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp index e485f76c921..d97f55bcde0 100644 --- a/cpp/src/Glacier2/SessionRouterI.cpp +++ b/cpp/src/Glacier2/SessionRouterI.cpp @@ -1125,7 +1125,12 @@ SessionRouterI::expireSessions() RouterIPtr SessionRouterI::getRouterImpl(const ConnectionPtr& connection, const Ice::Identity& id, bool close) const { - if(_destroy) + // + // The connection can be null if the client tries to forward requests to + // a proxy which points to the client endpoints (in which case the request + // is forwarded with collocation optimization). + // + if(_destroy || !connection) { throw ObjectNotExistException(__FILE__, __LINE__); } diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 09508a02737..9b1b186d56d 100755 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -780,6 +780,35 @@ getAddressStorageSize(const Address& addr) return size; } +vector<Address> +getLoopbackAddresses(ProtocolSupport protocol, int port = 0) +{ + vector<Address> result; + + Address addr; + memset(&addr.saStorage, 0, sizeof(sockaddr_storage)); + + // + // We don't use getaddrinfo when host is empty as it's not portable (some old Linux + // versions don't support it). + // + if(protocol != EnableIPv4) + { + addr.saIn6.sin6_family = AF_INET6; + addr.saIn6.sin6_port = htons(port); + addr.saIn6.sin6_addr = in6addr_loopback; + result.push_back(addr); + } + if(protocol != EnableIPv6) + { + addr.saIn.sin_family = AF_INET; + addr.saIn.sin_port = htons(port); + addr.saIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + result.push_back(addr); + } + return result; +} + #endif // #ifndef ICE_OS_UWP } @@ -1055,9 +1084,6 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol bool preferIPv6, bool canBlock) { vector<Address> result; - Address addr; - - memset(&addr.saStorage, 0, sizeof(sockaddr_storage)); // // We don't use getaddrinfo when host is empty as it's not portable (some old Linux @@ -1065,24 +1091,14 @@ IceInternal::getAddresses(const string& host, int port, ProtocolSupport protocol // if(host.empty()) { - if(protocol != EnableIPv4) - { - addr.saIn6.sin6_family = AF_INET6; - addr.saIn6.sin6_port = htons(port); - addr.saIn6.sin6_addr = in6addr_loopback; - result.push_back(addr); - } - if(protocol != EnableIPv6) - { - addr.saIn.sin_family = AF_INET; - addr.saIn.sin_port = htons(port); - addr.saIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - result.push_back(addr); - } + result = getLoopbackAddresses(protocol, port); sortAddresses(result, protocol, selType, preferIPv6); return result; } + Address addr; + memset(&addr.saStorage, 0, sizeof(sockaddr_storage)); + struct addrinfo* info = 0; int retry = 5; @@ -1218,7 +1234,8 @@ IceInternal::getAddressForServer(const string& host, int port, ProtocolSupport p #endif return addr; } - vector<Address> addrs = getAddresses(host, port, protocol, Ice::ICE_ENUM(EndpointSelectionType, Ordered), preferIPv6, canBlock); + vector<Address> addrs = getAddresses(host, port, protocol, Ice::ICE_ENUM(EndpointSelectionType, Ordered), + preferIPv6, canBlock); return addrs.empty() ? Address() : addrs[0]; } @@ -1640,7 +1657,7 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto hosts.push_back(wstringToString(h->CanonicalName->Data(), getProcessStringConverter())); } } - if(includeLoopback) + if(hosts.empty() || includeLoopback) { if(protocolSupport != EnableIPv6) { @@ -1686,6 +1703,15 @@ IceInternal::getHostsForEndpointExpand(const string& host, ProtocolSupport proto hosts.push_back(inetAddrToString(*p)); } } + if(hosts.empty()) + { + // Return loopback if no other local addresses are available. + addrs = getLoopbackAddresses(protocolSupport); + for(vector<Address>::const_iterator p = addrs.begin(); p != addrs.end(); ++p) + { + hosts.push_back(inetAddrToString(*p)); + } + } } return hosts; // An empty host list indicates to just use the given host. } |