summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-05-31 00:08:10 +0000
committerMarc Laukien <marc@zeroc.com>2002-05-31 00:08:10 +0000
commitf59d63d73f52dc2dad7390b43f964196e369df92 (patch)
tree6e5093e7d628f52ba0ec5061b611930508a5d74f /java/src
parentglacier batching fixes (diff)
downloadice-f59d63d73f52dc2dad7390b43f964196e369df92.tar.bz2
ice-f59d63d73f52dc2dad7390b43f964196e369df92.tar.xz
ice-f59d63d73f52dc2dad7390b43f964196e369df92.zip
fixed thread pool registration bug
Diffstat (limited to 'java/src')
-rw-r--r--java/src/IceInternal/Connection.java68
-rw-r--r--java/src/IceInternal/IncomingConnectionFactory.java29
2 files changed, 59 insertions, 38 deletions
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java
index ce5f649f484..508e6564011 100644
--- a/java/src/IceInternal/Connection.java
+++ b/java/src/IceInternal/Connection.java
@@ -698,6 +698,7 @@ public final class Connection extends EventHandler
_proxyUsageCount = 0;
_state = StateHolding;
_warn = _instance.properties().getPropertyAsInt("Ice.ConnectionWarnings") > 0 ? true : false;
+ _registeredWithPool = false;
}
protected void
@@ -893,39 +894,49 @@ public final class Connection extends EventHandler
private void
registerWithPool()
{
- if (_adapter != null)
- {
- if (_serverThreadPool == null)
- {
- _serverThreadPool = _instance.serverThreadPool();
- assert(_serverThreadPool != null);
- }
- _serverThreadPool._register(_transceiver.fd(), this);
- }
- else
- {
- if (_clientThreadPool == null)
- {
- _clientThreadPool = _instance.clientThreadPool();
- assert(_clientThreadPool != null);
- }
- _clientThreadPool._register(_transceiver.fd(), this);
- }
+ if (!_registeredWithPool)
+ {
+ if (_adapter != null)
+ {
+ if (_serverThreadPool == null)
+ {
+ _serverThreadPool = _instance.serverThreadPool();
+ assert(_serverThreadPool != null);
+ }
+ _serverThreadPool._register(_transceiver.fd(), this);
+ }
+ else
+ {
+ if (_clientThreadPool == null)
+ {
+ _clientThreadPool = _instance.clientThreadPool();
+ assert(_clientThreadPool != null);
+ }
+ _clientThreadPool._register(_transceiver.fd(), this);
+ }
+
+ _registeredWithPool = true;
+ }
}
private void
unregisterWithPool()
{
- if (_adapter != null)
- {
- assert(_serverThreadPool != null);
- _serverThreadPool.unregister(_transceiver.fd());
- }
- else
- {
- assert(_clientThreadPool != null);
- _clientThreadPool.unregister(_transceiver.fd());
- }
+ if (_registeredWithPool)
+ {
+ if (_adapter != null)
+ {
+ assert(_serverThreadPool != null);
+ _serverThreadPool.unregister(_transceiver.fd());
+ }
+ else
+ {
+ assert(_clientThreadPool != null);
+ _clientThreadPool.unregister(_transceiver.fd());
+ }
+
+ _registeredWithPool = false;
+ }
}
private void
@@ -979,6 +990,7 @@ public final class Connection extends EventHandler
private int _proxyUsageCount;
private int _state;
private boolean _warn;
+ private boolean _registeredWithPool;
private RecursiveMutex _mutex = new RecursiveMutex();
private Incoming _incomingCache;
}
diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java
index 061e1c90b82..82862a9f79c 100644
--- a/java/src/IceInternal/IncomingConnectionFactory.java
+++ b/java/src/IceInternal/IncomingConnectionFactory.java
@@ -199,8 +199,7 @@ public class IncomingConnectionFactory extends EventHandler
*/
public
- IncomingConnectionFactory(Instance instance, Endpoint endpoint,
- Ice.ObjectAdapter adapter)
+ IncomingConnectionFactory(Instance instance, Endpoint endpoint, Ice.ObjectAdapter adapter)
{
super(instance);
_endpoint = endpoint;
@@ -213,6 +212,7 @@ public class IncomingConnectionFactory extends EventHandler
_state = StateHolding;
_warn = _instance.properties().getPropertyAsInt("Ice.ConnectionWarnings") > 0 ? true : false;
_finished = false;
+ _registeredWithPool = false;
try
{
@@ -358,12 +358,16 @@ public class IncomingConnectionFactory extends EventHandler
{
if (_acceptor != null)
{
- if (_serverThreadPool == null)
- {
- _serverThreadPool = _instance.serverThreadPool();
- assert(_serverThreadPool != null);
- }
- _serverThreadPool._register(_acceptor.fd(), this);
+ if (!_registeredWithPool)
+ {
+ if (_serverThreadPool == null)
+ {
+ _serverThreadPool = _instance.serverThreadPool();
+ assert(_serverThreadPool != null);
+ }
+ _serverThreadPool._register(_acceptor.fd(), this);
+ _registeredWithPool = true;
+ }
}
}
@@ -372,8 +376,12 @@ public class IncomingConnectionFactory extends EventHandler
{
if (_acceptor != null)
{
- assert(_serverThreadPool != null);
- _serverThreadPool.unregister(_acceptor.fd());
+ if (!_registeredWithPool)
+ {
+ assert(_serverThreadPool != null);
+ _serverThreadPool.unregister(_acceptor.fd());
+ _registeredWithPool = true;
+ }
}
}
@@ -397,4 +405,5 @@ public class IncomingConnectionFactory extends EventHandler
private int _state;
private boolean _warn;
private boolean _finished;
+ private boolean _registeredWithPool;
}