diff options
Diffstat (limited to 'cpp/src/Ice/Connection.cpp')
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 81e43236ce0..9bc3b1dbde9 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -63,7 +63,8 @@ IceInternal::Connection::decProxyUsageCount() { IceUtil::RecMutex::Lock sync(*this); assert(_proxyUsageCount > 0); - if (--_proxyUsageCount == 0) + --_proxyUsageCount; + if (_proxyUsageCount == 0 && !_adapter) { assert(_requests.empty()); setState(StateClosing); @@ -252,17 +253,32 @@ IceInternal::Connection::setAdapter(const ObjectAdapterPtr& adapter) { IceUtil::RecMutex::Lock sync(*this); - if (adapter && !_adapter) + // + // In closed and holding state, we are not registered with the + // thread pool. For all other states, we have to notify the thread + // pool in case this event handler changed from a client to a + // server or vice versa. + // + if (_state != StateHolding && _state != StateClosed) { - _threadPool->clientIsNowServer(); + if (adapter && !_adapter) + { + _threadPool->clientIsNowServer(); + } + + if (!adapter && _adapter) + { + _threadPool->serverIsNowClient(); + } } - if (!adapter && _adapter) + _adapter = adapter; + + if (_proxyUsageCount == 0 && !_adapter) { - _threadPool->serverIsNowClient(); + assert(_requests.empty()); + setState(StateClosing); } - - _adapter = adapter; } ObjectAdapterPtr |