summaryrefslogtreecommitdiff
path: root/java/src/Ice/ObjectAdapterI.java
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-12-18 23:07:40 +0000
committerMarc Laukien <marc@zeroc.com>2002-12-18 23:07:40 +0000
commitf9f84256f069534d1aa2d2da1652648b75e9c4bb (patch)
tree46146ad5b5e204900c0439c57ed2828befa28dd9 /java/src/Ice/ObjectAdapterI.java
parentAppend service name to program name (diff)
downloadice-f9f84256f069534d1aa2d2da1652648b75e9c4bb.tar.bz2
ice-f9f84256f069534d1aa2d2da1652648b75e9c4bb.tar.xz
ice-f9f84256f069534d1aa2d2da1652648b75e9c4bb.zip
fix to waitForShutdown/Deactivate
Diffstat (limited to 'java/src/Ice/ObjectAdapterI.java')
-rw-r--r--java/src/Ice/ObjectAdapterI.java80
1 files changed, 51 insertions, 29 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java
index 097e53c9cb5..bccbf33da4d 100644
--- a/java/src/Ice/ObjectAdapterI.java
+++ b/java/src/Ice/ObjectAdapterI.java
@@ -150,8 +150,6 @@ public class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapter
public void
waitForDeactivate()
{
- java.util.HashMap locatorMap;
-
synchronized(this)
{
//
@@ -169,40 +167,52 @@ public class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapter
{
}
}
-
+
//
- // Now we wait for until all incoming connection factories are
- // finished.
+ // If some other thread is currently deactivating, we wait
+ // until this thread is finished.
//
- final int sz = _incomingConnectionFactories.size();
- for(int i = 0; i < sz; ++i)
+ while(_waitForDeactivate)
{
- IceInternal.IncomingConnectionFactory factory =
- (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i);
- factory.waitUntilFinished();
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
}
-
- //
- // We're done, now we can throw away all incoming connection
- // factories.
- //
- _incomingConnectionFactories.clear();
+ _waitForDeactivate = true;
+ }
- //
- // Now it's also time to clean up the active servant map.
- //
- _activeServantMap.clear();
- //
- // And the servant locators, too (first we make a copy of
- // the map in order to invoke servant locator deactivate
- // method outside the synchronization block).
- //
- locatorMap = new java.util.HashMap(_locatorMap);
- _locatorMap.clear();
+ //
+ // Now we wait for until all incoming connection factories are
+ // finished.
+ //
+ final int sz = _incomingConnectionFactories.size();
+ for(int i = 0; i < sz; ++i)
+ {
+ IceInternal.IncomingConnectionFactory factory =
+ (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i);
+ factory.waitUntilFinished();
}
-
- java.util.Iterator p = locatorMap.entrySet().iterator();
+
+ //
+ // We're done, now we can throw away all incoming connection
+ // factories.
+ //
+ _incomingConnectionFactories.clear();
+
+ //
+ // Now it's also time to clean up the active servant map.
+ //
+ _activeServantMap.clear();
+
+ //
+ // And the servant locators, too.
+ //
+ java.util.Iterator p = _locatorMap.entrySet().iterator();
while(p.hasNext())
{
java.util.Map.Entry e = (java.util.Map.Entry)p.next();
@@ -222,6 +232,15 @@ public class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapter
_logger.error(s);
}
}
+
+ synchronized(this)
+ {
+ //
+ // Signal that waiting is complete.
+ //
+ _waitForDeactivate = false;
+ notifyAll();
+ }
}
public synchronized ObjectPrx
@@ -503,6 +522,7 @@ public class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapter
_id = id;
_logger = instance.logger();
_directCount = 0;
+ _waitForDeactivate = false;
String s = endpts.toLowerCase();
@@ -564,6 +584,7 @@ public class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapter
assert(_activeServantMap.size() == 0);
assert(_locatorMap.size() == 0);
assert(_directCount == 0);
+ assert(!_waitForDeactivate);
}
super.finalize();
@@ -743,4 +764,5 @@ public class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapter
private java.util.ArrayList _routerEndpoints = new java.util.ArrayList();
private IceInternal.LocatorInfo _locatorInfo;
private int _directCount;
+ private boolean _waitForDeactivate;
}