diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-08-24 05:37:28 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-08-24 05:37:28 +0000 |
commit | edebcc852d28935a734e2e589fc43a9013f98944 (patch) | |
tree | 83a1333a883e8b0b8cfb8dd6b5cf5f8b43a639c3 /java/src/Ice/ObjectAdapterI.java | |
parent | synchronized java & C++ version of ObjectAdapter::deactivate. Use (diff) | |
download | ice-edebcc852d28935a734e2e589fc43a9013f98944.tar.bz2 ice-edebcc852d28935a734e2e589fc43a9013f98944.tar.xz ice-edebcc852d28935a734e2e589fc43a9013f98944.zip |
Synchronized java & C++ version of ObjectAdapter::deactivate
Diffstat (limited to 'java/src/Ice/ObjectAdapterI.java')
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index 20274d2c554..227255d1def 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -178,31 +178,49 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt } } - public synchronized void + public void deactivate() { - // - // Ignore deactivation requests if the object adapter has - // already been deactivated. - // - if(_deactivated) + IceInternal.OutgoingConnectionFactory outgoingConnectionFactory; + java.util.ArrayList incomingConnectionFactories; + synchronized(this) { - return; + // + // Ignore deactivation requests if the object adapter has + // already been deactivated. + // + if(_deactivated) + { + return; + } + + incomingConnectionFactories = new java.util.ArrayList(_incomingConnectionFactories); + outgoingConnectionFactory = _instance.outgoingConnectionFactory(); + + _deactivated = true; + + notifyAll(); } - - final int sz = _incomingConnectionFactories.size(); + + // + // Must be called outside the thread synchronization, because + // Connection::destroy() might block when sending a CloseConnection + // message. + // + final int sz = incomingConnectionFactories.size(); for(int i = 0; i < sz; ++i) { IceInternal.IncomingConnectionFactory factory = - (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); + (IceInternal.IncomingConnectionFactory)incomingConnectionFactories.get(i); factory.destroy(); } - - _instance.outgoingConnectionFactory().removeAdapter(this); - - _deactivated = true; - - notifyAll(); + + // + // Must be called outside the thread synchronization, because + // changing the object adapter might block if there are still + // requests being dispatched. + // + outgoingConnectionFactory.removeAdapter(this); } public void |