for closing connection, reserve entry only when it is past idle time or

evicted, not otherwise
pull/383/head
Nitin 10 years ago
parent ebe5868fd1
commit 6a2bfb758c

@ -627,21 +627,20 @@ public class HikariPool implements HikariPoolMXBean, IBagStateListener
fillPool();
return;
}
else {
previous = now;
}
logPoolState("Before cleanup\t");
final List<PoolBagEntry> bag = connectionBag.values(STATE_NOT_IN_USE);
int removable = bag.size() - config.getMinimumIdle();
for (PoolBagEntry bagEntry : bag) {
if (removable > 0 && connectionBag.reserve(bagEntry)) {
if (idleTimeout > 0L && clockSource.elapsedMillis(bagEntry.lastAccess, now) > idleTimeout) {
if (removable > 0 && (bagEntry.evicted || (idleTimeout > 0L && clockSource.elapsedMillis(bagEntry.lastAccess, now) > idleTimeout))) {
if (connectionBag.reserve(bagEntry)) {
closeConnection(bagEntry, "(connection passed idleTimeout)");
removable--;
}
else {
connectionBag.unreserve(bagEntry);
bagEntry.evicted = true;
}
}
}

Loading…
Cancel
Save