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 | |
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')
-rw-r--r-- | cpp/include/Ice/Initialize.h | 4 | ||||
-rw-r--r-- | cpp/src/Glacier2/SessionRouterI.cpp | 7 | ||||
-rwxr-xr-x | cpp/src/Ice/Network.cpp | 64 | ||||
-rw-r--r-- | cpp/test/Glacier2/router/Client.cpp | 13 | ||||
-rw-r--r-- | cpp/test/uwp/controller/App.xaml.cpp | 34 | ||||
-rw-r--r-- | cpp/test/uwp/controller/App.xaml.h | 2 | ||||
-rw-r--r-- | cpp/test/uwp/controller/Package.appxmanifest | 4 |
7 files changed, 102 insertions, 26 deletions
diff --git a/cpp/include/Ice/Initialize.h b/cpp/include/Ice/Initialize.h index 15964d54998..f595b126194 100644 --- a/cpp/include/Ice/Initialize.h +++ b/cpp/include/Ice/Initialize.h @@ -659,7 +659,7 @@ public: * Adopts the given communicator. * @param communicator The new communicator instance to hold. */ - explicit CommunicatorHolder(std::shared_ptr<Communicator> communicator); + CommunicatorHolder(std::shared_ptr<Communicator> communicator); /** * Adopts the given communicator. If this holder currently holds a communicator, @@ -869,7 +869,7 @@ public: * Adopts the given communicator. * @param communicator The new communicator instance to hold. */ - explicit CommunicatorHolder(const CommunicatorPtr& communicator); + CommunicatorHolder(const CommunicatorPtr& communicator); /** * Adopts the given communicator. If this holder currently holds a communicator, 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. } diff --git a/cpp/test/Glacier2/router/Client.cpp b/cpp/test/Glacier2/router/Client.cpp index 778e02ea4ea..afa70d92013 100644 --- a/cpp/test/Glacier2/router/Client.cpp +++ b/cpp/test/Glacier2/router/Client.cpp @@ -554,6 +554,19 @@ CallbackClient::run(int argc, char* argv[]) cout << "ok" << endl; } + { + cout << "pinging object with client endpoint... " << flush; + Ice::ObjectPrx baseC = communicator()->stringToProxy("collocated:" + getTestEndpoint(communicator(), 50)); + try + { + baseC->ice_ping(); + } + catch(const Ice::ObjectNotExistException&) + { + } + cout << "ok" << endl; + } + CallbackPrx twoway; { diff --git a/cpp/test/uwp/controller/App.xaml.cpp b/cpp/test/uwp/controller/App.xaml.cpp index ea67c113cc6..dfb97c7000d 100644 --- a/cpp/test/uwp/controller/App.xaml.cpp +++ b/cpp/test/uwp/controller/App.xaml.cpp @@ -9,6 +9,7 @@ #include "pch.h" #include "ViewController.xaml.h" +#include <ppltasks.h> using namespace Controller; @@ -25,6 +26,7 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Interop; using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Navigation; +using namespace Windows::ApplicationModel::ExtendedExecution::Foreground; // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 @@ -48,20 +50,20 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent { // Do not repeat app initialization when already running, just ensure that // the window is active - if (pArgs->PreviousExecutionState == ApplicationExecutionState::Running) + if(pArgs->PreviousExecutionState == ApplicationExecutionState::Running) { Window::Current->Activate(); return; } - if (pArgs->PreviousExecutionState == ApplicationExecutionState::Terminated) + if(pArgs->PreviousExecutionState == ApplicationExecutionState::Terminated) { //TODO: Load state from previously suspended application } // Create a Frame to act navigation context and navigate to the first page auto rootFrame = ref new Frame(); - if (!rootFrame->Navigate(TypeName(ViewController::typeid))) + if(!rootFrame->Navigate(TypeName(ViewController::typeid))) { throw ref new FailureException("Failed to create initial page"); } @@ -69,6 +71,32 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent // Place the frame in the current Window and ensure that it is active Window::Current->Content = rootFrame; Window::Current->Activate(); + + if(!_session) + { + ExtendedExecutionForegroundSession^ session = ref new ExtendedExecutionForegroundSession(); + session->Reason = ExtendedExecutionForegroundReason::Unconstrained; + session->Revoked += ref new TypedEventHandler<Object^, ExtendedExecutionForegroundRevokedEventArgs^>(this, &App::SessionRevoked); + concurrency::create_task(session->RequestExtensionAsync()).then([this, session](ExtendedExecutionForegroundResult result) + { + switch(result) + { + case ExtendedExecutionForegroundResult::Allowed: + _session = session; + break; + case ExtendedExecutionForegroundResult::Denied: + break; + } + }); + } +} + +void App::SessionRevoked(Object^ sender, ExtendedExecutionForegroundRevokedEventArgs^ args) +{ + if(_session != nullptr) + { + _session = nullptr; + } } /// <summary> diff --git a/cpp/test/uwp/controller/App.xaml.h b/cpp/test/uwp/controller/App.xaml.h index 354d2726504..2305d464a81 100644 --- a/cpp/test/uwp/controller/App.xaml.h +++ b/cpp/test/uwp/controller/App.xaml.h @@ -24,5 +24,7 @@ public: private: void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); + void SessionRevoked(Platform::Object^, Windows::ApplicationModel::ExtendedExecution::Foreground::ExtendedExecutionForegroundRevokedEventArgs^); + Windows::ApplicationModel::ExtendedExecution::Foreground::ExtendedExecutionForegroundSession^ _session; }; } diff --git a/cpp/test/uwp/controller/Package.appxmanifest b/cpp/test/uwp/controller/Package.appxmanifest index e5a1aa1d6f5..85f47d15719 100644 --- a/cpp/test/uwp/controller/Package.appxmanifest +++ b/cpp/test/uwp/controller/Package.appxmanifest @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp"> +<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap"> <Identity Name="ice-uwp-controller" Publisher="CN=ZeroC" Version="1.0.0.0" /> <mp:PhoneIdentity PhoneProductId="f4c6cdff-3ef9-43fb-8094-d50c547e70f6" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> <Properties> @@ -26,6 +26,8 @@ <Capability Name="internetClientServer" /> <Capability Name="internetClient" /> <Capability Name="privateNetworkClientServer" /> + <rescap:Capability Name="extendedBackgroundTaskTime" /> + <rescap:Capability Name="extendedExecutionUnconstrained" /> </Capabilities> <Extensions> <Extension Category="windows.certificates"> |