private synchronized void freeClient ( Client client ) { int current = useCounts . get ( client ) ; if ( current > 0 ) { timestamps . put ( client , System . currentTimeMillis ( ) ) ; // Mark that it was used until now. useCounts . put ( client , current - 1 ) ; if ( ( current == 1 ) && ( idleLimit . get ( ) == 0 ) ) { closeClient ( client ) ; // This was the last use, and we are supposed to immediately close idle clients. } } else { logger . error ( "Ignoring attempt to free a client that is not allocated: {}" , client ) ; } }
Decrements the client s use count and makes it eligible for closing if it is no longer in use .