Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8707A9046 for ; Wed, 3 Oct 2012 02:30:08 +0000 (UTC) Received: (qmail 49326 invoked by uid 500); 3 Oct 2012 02:30:08 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 49265 invoked by uid 500); 3 Oct 2012 02:30:08 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 49147 invoked by uid 99); 3 Oct 2012 02:30:08 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2012 02:30:08 +0000 Date: Wed, 3 Oct 2012 13:30:08 +1100 (NCT) From: "Scott Stanton (JIRA)" To: dev@hc.apache.org Message-ID: <930791555.157350.1349231408203.JavaMail.jiratomcat@arcas> In-Reply-To: <49067517.157221.1349226727565.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (HTTPCORE-315) HttpAsyncRequester leaks a connection if a request is cancelled before the connection is established MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCORE-315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13468265#comment-13468265 ] Scott Stanton commented on HTTPCORE-315: ---------------------------------------- I have attached a possible fix for this issue. Splitting the RouteSpecificPool.completed() call into createEntry() and completed() allows the requestCompleted() method to add the entry to the global leased list before calling completed(). > HttpAsyncRequester leaks a connection if a request is cancelled before the connection is established > ---------------------------------------------------------------------------------------------------- > > Key: HTTPCORE-315 > URL: https://issues.apache.org/jira/browse/HTTPCORE-315 > Project: HttpComponents HttpCore > Issue Type: Bug > Components: HttpCore NIO > Affects Versions: 4.2.2 > Reporter: Scott Stanton > Attachments: HTTPCORE-315.patch > > > When using HttpAsyncRequester in combination with a BasicNIOConnPool, if the future returned from execute() is cancelled before the connection is established, then the connection will be leaked after it connects (added to the leased list after the cancelled() callbacks are invoked). The sequence that leads to this is: > * AbstractNIOConnPool.requestCompleted() calls RouteSpecificPool.completed() which ultimately calls HttpAsyncRequester.completed() > * HttpAsyncRequester.completed() detects that the requestFuture is done, so it attempts to release the pool entry > * The pool entry hasn't been added to the leased list yet, so the release has no effect and the connection is not added to the available list > * After the completed callback returns to requestCompleted(), the connection is added to the leased list. > At this point, no thread is expecting to do anything further with the connection, so it is effectively lost and consuming a pool slot. > I think the correct remedy is to ensure that the connection is added to the global leased list as well as the route specific leased list before the completed() callback is invoked. This should ensure that the connection is properly cleaned up. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org