protected void removeMCWrapperFromList ( MCWrapper mcWrapper , boolean removeFromFreePool , boolean synchronizationNeeded , boolean skipWaiterNotify , boolean decrementTotalCounter ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . entry ( this , tc , "removeMCWrapperFromList" ) ; } /* * This cast to UserData is safe, and does not need a * try/catch. */ if ( synchronizationNeeded ) { synchronized ( pm . waiterFreePoolLock ) { synchronized ( freeConnectionLockObject ) { if ( removeFromFreePool ) { // mcWrapper may not be in the free pool mcWrapperList . remove ( mcWrapper ) ; mcWrapper . setPoolState ( 0 ) ; } -- numberOfConnectionsAssignedToThisFreePool ; if ( decrementTotalCounter ) { pm . totalConnectionCount . decrementAndGet ( ) ; } if ( ! skipWaiterNotify ) { // waiter code //synchronized(pm.waiterFreePoolLock) { pm . waiterFreePoolLock . notify ( ) ; //} } } } } else { if ( removeFromFreePool ) { // mcWrapper may not be in the free pool mcWrapperList . remove ( mcWrapper ) ; mcWrapper . setPoolState ( 0 ) ; -- numberOfConnectionsAssignedToThisFreePool ; } if ( decrementTotalCounter ) { pm . totalConnectionCount . decrementAndGet ( ) ; } // This code block may dead lock if we have the freePool lock and need to notify. // Since the current code does not use the notify code I am // commenting out the follow notify code //if (!skipWaiterNotify) { // waiter code // synchronized(pm.waiterFreePoolLock) { // pm.waiterFreePoolLock.notify(); // } //} } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( this , tc , "removeMCWrapperFromList" ) ; } }
This method will try to cleanup and destroy the connection and remove the mcWrapper from the free pool .