We think it is better here to not call removeConnection if we can find any 
reason not to. That is why we want to do the compareAndSet before calling 
removeConnection. If some other thread concurrently decremented connectionCount 
then we don't want to call removeConnection. removeConnection is synchronized 
and this method (destroyIfOverLimit) is called every time we return a 
connection to the pool which will happens for every client op. Right before we 
called destroyIfOverLimit we checked if the current connection was already 
destroyed or had been marked for destruction. If either of these was true then 
we would not call it. So I think the only case in which we could end up decing 
and then incing in the else, is when we had a concurrent invocation of the 
membership listener that a server crashed. In that case we are going to do a 
bunch of decs anyway for all the connections on that server. And if we do end 
up over the max in this window then this method (destroyIfOverLimit) will corre
 ct it the next time it is called.

[ Full content available at: https://github.com/apache/geode/pull/3304 ]
This message was relayed via gitbox.apache.org for 
[email protected]

Reply via email to