diff -r 5de73d2d685e src/share/classes/com/sun/corba/se/impl/transport/CorbaConnectionCacheBase.java --- a/src/share/classes/com/sun/corba/se/impl/transport/CorbaConnectionCacheBase.java Mon Dec 01 13:38:26 2008 -0800 +++ b/src/share/classes/com/sun/corba/se/impl/transport/CorbaConnectionCacheBase.java Mon Jan 19 15:54:38 2009 +1100 @@ -175,10 +175,36 @@ Object backingStore = backingStore(); synchronized (backingStore) { + + long idleCount = 0; + + // count the idle connections + Iterator connections = values().iterator(); + while (connections.hasNext()) { + if (! ((Connection)connections.next()).isBusy()) { + idleCount++; + } + } + + // adjust the number of connections to reclaim as follows: + // If the number of idle connections (including new connections) + // is between 2 and 5, exclude the new connections from + // reclamation. + // -> In case of 1 idle connection, this connection itself would + // be reclaimed, leading to an exception. + // -> In case of 2-5 idle connections, exclude the new + // connections. + // -> In case of 6 or more connections, reclaim 5 connections + // with the lowest timeStamp. + long reclaimcount = orb.getORBData().getNumberToReclaim(); + if(( 1 < idleCount ) && ( idleCount <= reclaimcount )) { + reclaimcount = idleCount - 1 ; + } + // REVISIT - A less expensive alternative connection reclaiming // algorithm could be investigated. - for (int i=0; i < orb.getORBData().getNumberToReclaim(); i++) { + for (int i=0; i < reclaimcount; i++) { Connection toClose = null; long lru = java.lang.Long.MAX_VALUE; Iterator iterator = values().iterator(); diff -r 5de73d2d685e src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java --- a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java Mon Dec 01 13:38:26 2008 -0800 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java Mon Jan 19 15:54:38 2009 +1100 @@ -307,6 +307,15 @@ } getConnectionCache().reclaim(); + + // make sure connections that were not used for communication are + // reclaimed in oldest first order too. + try { + getConnectionCache().stampTime(connection); + } + catch (Exception ex) { + // okay to ignore + } } public void close () diff -r 5de73d2d685e src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java --- a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java Mon Dec 01 13:38:26 2008 -0800 +++ b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java Mon Jan 19 15:54:38 2009 +1100 @@ -138,7 +138,7 @@ // protected Socket socket; // The socket used for this connection. - protected long timeStamp = 0; + protected long timeStamp = java.lang.Long.MAX_VALUE - 1; protected boolean isServer = false; // Start at some value other than zero since this is a magic