diff options
author | Joe George <joe@zeroc.com> | 2015-09-11 14:30:00 -0400 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2015-09-11 14:30:00 -0400 |
commit | b9c2a6f6628476f11c78a7de2adc90edca1e209e (patch) | |
tree | df192d87dfbc594a7a2b52a96b5145ad3156d26f /cpp/src/Glacier2Lib/SessionHelper.cpp | |
parent | ICE-6645 Removed hack to keep binary compatibility in Ice 3.6.1 (diff) | |
parent | Removed ARM configuraton from WinRT testsuite solutions (diff) | |
download | ice-b9c2a6f6628476f11c78a7de2adc90edca1e209e.tar.bz2 ice-b9c2a6f6628476f11c78a7de2adc90edca1e209e.tar.xz ice-b9c2a6f6628476f11c78a7de2adc90edca1e209e.zip |
Merge remote-tracking branch 'origin/3.6'
Diffstat (limited to 'cpp/src/Glacier2Lib/SessionHelper.cpp')
-rw-r--r-- | cpp/src/Glacier2Lib/SessionHelper.cpp | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp index 0ebfeaa98aa..7ce2d2c3eb9 100644 --- a/cpp/src/Glacier2Lib/SessionHelper.cpp +++ b/cpp/src/Glacier2Lib/SessionHelper.cpp @@ -94,6 +94,7 @@ public: Ice::ObjectAdapterPtr objectAdapter(); friend class DestroyInternal; + friend class DestroyCommunicator; friend class ConnectThread; friend class DispatchCallThread; friend class Glacier2::SessionFactoryHelper; @@ -103,6 +104,7 @@ private: Ice::ObjectAdapterPtr internalObjectAdapter(); void connected(const Glacier2::RouterPrx&, const Glacier2::SessionPrx&); void destroyInternal(const Ice::DispatcherCallPtr&); + void destroyCommunicator(); void connectFailed(); void connect(const std::map<std::string, std::string>&); @@ -163,6 +165,27 @@ private: const Ice::DispatcherCallPtr _disconnected; }; +class DestroyCommunicator : public IceUtil::Thread +{ + +public: + + DestroyCommunicator(const SessionHelperIPtr& session) : + _session(session) + { + } + + virtual void run() + { + _session->destroyCommunicator(); + _session = 0; + } + +private: + + SessionHelperIPtr _session; +}; + } SessionHelperI::SessionHelperI(const Glacier2::SessionThreadCallbackPtr& threadCB, @@ -193,12 +216,13 @@ SessionHelperI::destroy() if(!_connected) { // - // In this case a connecting session is being - // destroyed. The communicator and session will be - // destroyed when the connection establishment has - // completed. + // In this case a connecting session is being destroyed. + // We destroy the communicator to trigger the immediate + // failure of the connection establishment. // + IceUtil::ThreadPtr destroyCommunicator = new DestroyCommunicator(this); _threadCB = 0; + destroyCommunicator->start(); return; } @@ -424,6 +448,28 @@ SessionHelperI::destroyInternal(const Ice::DispatcherCallPtr& disconnected) } void +SessionHelperI::destroyCommunicator() +{ + Ice::CommunicatorPtr communicator; + { + IceUtil::Mutex::Lock sync(_mutex); + communicator = _communicator; + } + + if(communicator) + { + try + { + communicator->destroy(); + } + catch(...) + { + } + communicator = 0; + } +} + +void SessionHelperI::connectFailed() { Ice::CommunicatorPtr communicator; @@ -526,6 +572,11 @@ public: { _communicator->setDefaultRouter(finder->getRouter()); } + catch(const Ice::CommunicatorDestroyedException& ex) + { + _session->dispatchCallback(new ConnectFailed(_callback, _session, ex), 0); + return; + } catch(const Ice::Exception&) { // |