diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Ice/OutgoingAsync.cpp | 15 |
2 files changed, 21 insertions, 16 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index fd740488944..d35c4177995 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -201,10 +201,16 @@ IceInternal::Connection::decProxyCount() IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); assert(_proxyCount > 0); --_proxyCount; - if(_proxyCount == 0 && !_adapter) + + // + // We close the connection if + // - no proxy uses this connection anymore; and + // - there are not outstanding asynchronous requests; and + // - this is an outgoing connection only. + // + if(_proxyCount == 0 && _asyncRequests.empty() && !_adapter) { assert(_requests.empty()); - assert(_asyncRequests.empty()); setState(StateClosing, CloseConnectionException(__FILE__, __LINE__)); } } @@ -926,6 +932,18 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa { _asyncRequests.erase(q); } + + // + // We close the connection if + // - no proxy uses this connection anymore; and + // - there are not outstanding asynchronous requests; and + // - this is an outgoing connection only. + // + if(_proxyCount == 0 && _asyncRequests.empty() && !_adapter) + { + assert(_requests.empty()); + setState(StateClosing, CloseConnectionException(__FILE__, __LINE__)); + } } break; diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index bc7727cd933..dca96e8346e 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -80,16 +80,7 @@ IceInternal::OutgoingAsync::__setup(const ConnectionPtr& connection, const Refer void IceInternal::OutgoingAsync::__invoke() { - _connection->incProxyCount(); - try - { - _connection->sendAsyncRequest(this, _compress); - } - catch(...) - { - _connection->decProxyCount(); - throw; - } + _connection->sendAsyncRequest(this, _compress); } void @@ -200,8 +191,6 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is) { warning(); } - - _connection->decProxyCount(); } void @@ -223,8 +212,6 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc) { warning(); } - - _connection->decProxyCount(); } BasicStream* |