Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7AD9B18BCD for ; Wed, 27 Jan 2016 09:38:54 +0000 (UTC) Received: (qmail 38457 invoked by uid 500); 27 Jan 2016 09:38:49 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 38412 invoked by uid 500); 27 Jan 2016 09:38:49 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 38400 invoked by uid 99); 27 Jan 2016 09:38:49 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jan 2016 09:38:49 +0000 Received: from ok2c (84.76.106.92.dynamic.wline.res.cust.swisscom.ch [92.106.76.84]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 66D431A003F for ; Wed, 27 Jan 2016 09:38:48 +0000 (UTC) Message-ID: <1453887521.6398.4.camel@apache.org> Subject: Re: Close Hang From: Oleg Kalnichevski To: HttpClient User Discussion Date: Wed, 27 Jan 2016 10:38:41 +0100 In-Reply-To: <56A7C962.2030207@gmail.com> References: <56A2B5FA.4090706@gmail.com> <1453735568.18234.0.camel@apache.org> <56A7A687.4080108@gmail.com> <52ECC9F7-C072-400C-B0EE-362EC9869C57@ok2consulting.com> <56A7C962.2030207@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit On Tue, 2016-01-26 at 13:30 -0600, Mark Johnson wrote: > Hi Oleg, > > Below is a program that reproduces the hang. It might take a couple of > runs to make this happen - it depends on what thread the callback is > generated on. If it's on the IO Dispatcher thread, we can close the > connection on that thread also and there's no problem. If the callback > comes on the pool-thread the program hangs. The stack trace of the > pool-thread when this happens looks like this: > > Thread [pool-1-thread] (Suspended) <-- I paused it in the debugger > but this is where it stays > owns: SessionRequestImpl (id=44) > waiting for: Thread (id=21) > Object.wait(long) > Thread.join(long) > Thread.join() > InternalHttpAsyncClient(ClosableHttpAsyncClientBase).close() > Testprog$Callback.failed(Exception) > etc. ... > @Override > > public void cancelled() { > > Thread t = Thread.currentThread(); > > System.out.println(t.getName() + ": " + "Request cancelled"); > > try { > > System.out.println(t.getName() + ": " + "Closing client connection"); > > _httpclient.close(); > > } catch (Exception ex) { > > System.out.println(t.getName() + ": " + ex.getMessage()); > > } > > _latch.countDown(); > > } > Good Lord! You are shutting down the client from a callback. Is there a good reason for that? Regardless I'll see if there is a way to avoid a deadlock here. Thanks for the reproducer. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org