diff options
author | Mark Spruiell <mes@zeroc.com> | 2002-12-05 00:18:28 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2002-12-05 00:18:28 +0000 |
commit | db3284e2a762e2ca1bec7002e25221e0199ab66a (patch) | |
tree | d70aaada0e771af13bf19b784e8ebc8c5f1a7a49 /java/src/IceInternal/Connection.java | |
parent | increase Glacier's server thread pool size to avoid a deadlock due to IceJ (diff) | |
download | ice-db3284e2a762e2ca1bec7002e25221e0199ab66a.tar.bz2 ice-db3284e2a762e2ca1bec7002e25221e0199ab66a.tar.xz ice-db3284e2a762e2ca1bec7002e25221e0199ab66a.zip |
yet another fix for Incoming cache
Diffstat (limited to 'java/src/IceInternal/Connection.java')
-rw-r--r-- | java/src/IceInternal/Connection.java | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index fa44610a7aa..f34f167b245 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -611,9 +611,9 @@ public final class Connection extends EventHandler } catch(Ice.LocalException ex) { - _mutex.lock(); - reclaimIncoming(in); + reclaimIncoming(in); // Must be called outside of synchronization on _mutex. in = null; + _mutex.lock(); try { setState(StateClosed, ex); @@ -666,11 +666,6 @@ public final class Connection extends EventHandler } finally { - if(in != null) - { - reclaimIncoming(in); - in = null; - } _mutex.unlock(); } } @@ -679,9 +674,7 @@ public final class Connection extends EventHandler { if(in != null) { - _mutex.lock(); - reclaimIncoming(in); - _mutex.unlock(); + reclaimIncoming(in); // Must be called outside of synchronization on _mutex. } } } @@ -908,14 +901,7 @@ public final class Connection extends EventHandler registerWithPool(); } unregisterWithPool(); - // - // The cache of Incoming objects must be destroyed - // outside the synchronization on _mutex to avoid - // a potential deadlock with ObjectAdapter. - // - Incoming cache = _incomingCache; - _incomingCache = null; - new DestroyIncomingThread(cache).start(); + destroyIncomingCache(); break; } } @@ -1024,49 +1010,54 @@ public final class Connection extends EventHandler private Incoming getIncoming() { - Incoming in; - if(_incomingCache == null) - { - in = new Incoming(_instance, _adapter); - } - else + Incoming in = null; + + synchronized(_incomingCacheMutex) { - in = _incomingCache; - _incomingCache = _incomingCache.next; - in.next = null; - in.reset(_adapter); + if(_incomingCache == null) + { + in = new Incoming(_instance, _adapter); + } + else + { + in = _incomingCache; + _incomingCache = _incomingCache.next; + in.next = null; + in.reset(_adapter); + } } + return in; } private void reclaimIncoming(Incoming in) { - in.next = _incomingCache; - _incomingCache = in; + in.finished(); + + synchronized(_incomingCacheMutex) + { + in.next = _incomingCache; + _incomingCache = in; + } } - // - // Must be called outside of synchronization on _mutex. - // - private static class DestroyIncomingThread extends Thread + private void + destroyIncomingCache() { - DestroyIncomingThread(Incoming cache) + Incoming in = null; + + synchronized(_incomingCacheMutex) { - _cache = cache; + in = _incomingCache; + _incomingCache = null; } - public void - run() + while(in != null) { - while(_cache != null) - { - _cache.destroy(); - _cache = _cache.next; - } + in.destroy(); + in = in.next; } - - private Incoming _cache; } private final Transceiver _transceiver; @@ -1087,4 +1078,5 @@ public final class Connection extends EventHandler private boolean _registeredWithPool; private RecursiveMutex _mutex = new RecursiveMutex(); private Incoming _incomingCache; + private java.lang.Object _incomingCacheMutex = new java.lang.Object(); } |