diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-04-16 23:02:05 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-04-16 23:02:05 +0000 |
commit | f735a39d64deba47b416e41442d1321f9c972d8c (patch) | |
tree | 12a7b8ed7c594f13ee511cec9e409669e7ad90fd /java/src/IceInternal/Connection.java | |
parent | Win32 fixes for IceBox (diff) | |
download | ice-f735a39d64deba47b416e41442d1321f9c972d8c.tar.bz2 ice-f735a39d64deba47b416e41442d1321f9c972d8c.tar.xz ice-f735a39d64deba47b416e41442d1321f9c972d8c.zip |
align with C++ - fixes for the thread pool
Diffstat (limited to 'java/src/IceInternal/Connection.java')
-rw-r--r-- | java/src/IceInternal/Connection.java | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index f8ff8bca835..7e9162d9730 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -76,10 +76,11 @@ public final class Connection extends EventHandler try { assert(_proxyUsageCount >= 0); - if (--_proxyUsageCount == 0) + --_proxyUsageCount; + if (_proxyUsageCount == 0 && _adapter == null) { assert(_requests.isEmpty()); - setState(StateClosing); + setState(StateClosing, new Ice.CloseConnectionException()); } } finally @@ -285,6 +286,25 @@ public final class Connection extends EventHandler _mutex.lock(); try { + // + // 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) + { + if (adapter != null && _adapter == null) + { + _threadPool.clientIsNowServer(); + } + + if (adapter == null && _adapter != null) + { + _threadPool.serverIsNowClient(); + } + } + _adapter = adapter; } finally @@ -611,11 +631,14 @@ public final class Connection extends EventHandler _mutex.lock(); try { - _threadPool.promoteFollower(); + assert(_state == StateClosed || _state == StateHolding); - assert(_state == StateClosed); + _threadPool.promoteFollower(); - _transceiver.close(); + if (_state == StateClosed) + { + _transceiver.close(); + } } finally { @@ -651,7 +674,7 @@ public final class Connection extends EventHandler try { - setState(StateClosing); + setState(StateClosing, new Ice.CloseConnectionException()); return true; } finally @@ -810,7 +833,7 @@ public final class Connection extends EventHandler { return; } - _threadPool.unregister(_transceiver.fd(), false); + _threadPool.unregister(_transceiver.fd()); break; } @@ -841,7 +864,7 @@ public final class Connection extends EventHandler // _threadPool._register(_transceiver.fd(), this); } - _threadPool.unregister(_transceiver.fd(), true); + _threadPool.unregister(_transceiver.fd()); break; } } |