Skip to content

Commit

Permalink
Fix trivial mistake when counting the number of active connections
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Jul 23, 2010
1 parent a67540d commit 531c59a
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -460,7 +460,8 @@ private <T> Future<T> doConnect(final Request request, final AsyncHandler<T> asy
}


if (config.getMaxTotalConnections() != -1 && activeConnectionsCount.getAndIncrement()>= config.getMaxTotalConnections()) {
if (config.getMaxTotalConnections() != -1 && activeConnectionsCount.getAndIncrement() >= config.getMaxTotalConnections()) {
activeConnectionsCount.decrementAndGet();
throw new IOException("Too many connections");
}

Expand Down Expand Up @@ -646,6 +647,7 @@ private void markAsDoneAndCacheConnection(final NettyResponseFuture<?> future, f
if (connectionPerHost.getAndIncrement() < config.getMaxConnectionPerHost()) {
connectionsPool.put(getBaseUrl(future.getURI()), channel);
} else {
connectionPerHost.decrementAndGet();
log.warn("Maximum connections per hosts reached " + config.getMaxConnectionPerHost());
}
} else {
Expand Down

1 comment on commit 531c59a

@jfarcand
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to say Thanks to Tatu Saloranta for spotting the issue.

Please sign in to comment.