HTTPCLIENT-677: no Thread.interrupt() for shutdown

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@607421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roland Weber 2007-12-29 14:40:44 +00:00
parent 7a2a85f25e
commit 540984183f
2 changed files with 8 additions and 16 deletions

View File

@ -1,8 +1,7 @@
Changes since 4.0 Alpha 2
-------------------
* [HTTPCLIENT-677] Thread safe client connection manager no longer uses
Thread.interrupt() when a connection becomes available.
* [HTTPCLIENT-677] Connection manager no longer uses Thread.interrupt()
Contributed by Roland Weber <rolandw at apache.org>
* [HTTPCLIENT-716] Allow application-defined routes.

View File

@ -239,27 +239,20 @@ public BasicPoolEntry getEntry(HttpRoute route, long timeout,
rospl.queueThread(waitingThread);
waitingThreads.add(waitingThread);
success = waitingThread.await(timeToWait); //@@@, TimeUnit.MILLISECONDS);
//@@@ The 'success' flag is somewhat different from the
//@@@ previous technique using interrupts. If the CM is
//@@@ shutting down, we now get an InterruptedException
//@@@ and have no check for that special case. What we
//@@@ want to do is to let the exception fly through.
//@@@ Actually, we may want to have a special exception
//@@@ for the shutdown case, but that is goldplating.
success = waitingThread.await(timeToWait); //@@@, TimeUnit.MILLISECONDS); or deadline
} finally {
if (!success) {
// Either we timed out, experienced a
// "spurious wakeup", or were interrupted by an
// external thread. Regardless we need to
// "spurious wakeup", or were interrupted by
// an external thread. Regardless, we need to
// cleanup for ourselves in the wait queue.
rospl.removeThread(waitingThread);
waitingThreads.remove(waitingThread);
}
// In case of 'success', we were woken up by the
// connection pool and should now have a connection
// waiting for us. Continue in the loop and get it.
// waiting for us, or else we're shutting down.
// Just continue in the loop, both cases are checked.
if (useTimeout) {
endWait = System.currentTimeMillis();
@ -571,12 +564,12 @@ public void shutdown() {
closeConnection(entry.getConnection());
}
// interrupt all waiting threads
// wake up all waiting threads
Iterator<WaitingThread> iwth = waitingThreads.iterator();
while (iwth.hasNext()) {
WaitingThread waiter = iwth.next();
iwth.remove();
waiter.getThread().interrupt();
waiter.wakeup();
}
routeToPool.clear();