diff options
author | Marc Laukien <marc@zeroc.com> | 2003-01-17 19:00:05 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2003-01-17 19:00:05 +0000 |
commit | eb111eeea20b1f6fb605eacd7c1a911e6bcd0630 (patch) | |
tree | ae3aaecc90830b924241ef1a22b9a60f1dd170b4 /cpp/src/Ice/Connection.cpp | |
parent | Fixed property name (diff) | |
download | ice-eb111eeea20b1f6fb605eacd7c1a911e6bcd0630.tar.bz2 ice-eb111eeea20b1f6fb605eacd7c1a911e6bcd0630.tar.xz ice-eb111eeea20b1f6fb605eacd7c1a911e6bcd0630.zip |
ConnectionMonitor
Diffstat (limited to 'cpp/src/Ice/Connection.cpp')
-rw-r--r-- | cpp/src/Ice/Connection.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp index 916d2a5e24f..7396104b38d 100644 --- a/cpp/src/Ice/Connection.cpp +++ b/cpp/src/Ice/Connection.cpp @@ -137,17 +137,17 @@ IceInternal::Connection::monitor() // // Active connection management for idle connections. // - if(_acmTimeout > 0) + if(_acmTimeout > 0 && + _requests.empty() && _asyncRequests.empty() && + _batchStream.b.empty() && + _dispatchCount == 0) { - if(_requests.empty() && _asyncRequests.empty() && _batchStream.b.empty() && _dispatchCount == 0) + if(IceUtil::Time::now() >= _acmAbsoluteTimeout) { - if(IceUtil::Time::now() >= _acmAbsoluteTimeout) - { - setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__)); - return; - } + setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__)); + return; } - } + } } catch(const IceUtil::ThreadLockedException&) { @@ -499,21 +499,26 @@ IceInternal::Connection::prepareBatchRequest(BasicStream* os) } assert(_state < StateClosing); - // - // The Connection now belongs to the caller, until - // finishBatchRequest() is called. - // - if(_batchStream.b.empty()) { - _batchStream.writeBlob(_requestBatchHdr); + try + { + _batchStream.writeBlob(_requestBatchHdr); + } + catch(const LocalException& ex) + { + setState(StateClosed, ex); + unlock(); + ex.ice_throw(); + } } + _batchStream.swap(*os); + // - // Give the batch stream to the caller, until finishBatchRequest() - // or abortBatchRequest() is called. + // The Connection and _batchStream now belongs to the caller, + // until finishBatchRequest() or abortBatchRequest() is called. // - _batchStream.swap(*os); } void @@ -543,6 +548,11 @@ IceInternal::Connection::flushBatchRequest(bool compress) { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + if(_batchStream.b.empty()) + { + return; // Nothing to send. + } + if(_exception.get()) { _exception->ice_throw(); @@ -551,11 +561,6 @@ IceInternal::Connection::flushBatchRequest(bool compress) try { - if(_batchStream.b.empty()) - { - return; // Nothing to send. - } - _batchStream.i = _batchStream.b.begin(); // |