diff options
author | Simone Bordet | 2014-04-07 15:31:25 +0000 |
---|---|---|
committer | Simone Bordet | 2014-04-10 06:59:30 +0000 |
commit | e3662a9b236a322abfc3743657d2f0e426a7b0f1 (patch) | |
tree | 5b0d1bb607f0d854dcefaae6e6ee84e72d16d9be /jetty-fcgi/fcgi-client | |
parent | 0e458c80f4763ac1b56c30cd7276a613c39f7343 (diff) | |
download | org.eclipse.jetty.project-e3662a9b236a322abfc3743657d2f0e426a7b0f1.tar.gz org.eclipse.jetty.project-e3662a9b236a322abfc3743657d2f0e426a7b0f1.tar.xz org.eclipse.jetty.project-e3662a9b236a322abfc3743657d2f0e426a7b0f1.zip |
432145 - Pending request is not failed when HttpClient is stopped.
Fixed by fixing the code in close() to also abort pending exchanges.
Reviewed for HTTP, FastCGI and SPDY transports.
Diffstat (limited to 'jetty-fcgi/fcgi-client')
2 files changed, 28 insertions, 13 deletions
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java index ac5687ef41..a6f7de6ec3 100644 --- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java +++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpChannelOverFCGI.java @@ -132,7 +132,7 @@ public class HttpChannelOverFCGI extends HttpChannel if (close) connection.close(); else - connection.release(); + connection.release(this); } protected void flush(Generator.Result... results) @@ -155,7 +155,7 @@ public class HttpChannelOverFCGI extends HttpChannel protected void onIdleExpired(TimeoutException timeout) { LOG.debug("Idle timeout for request {}", request); - abort(timeout); + connection.abort(timeout); } @Override diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java index 599455f970..262a7c498c 100644 --- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java +++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpConnectionOverFCGI.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.fcgi.client.http; import java.io.EOFException; import java.nio.ByteBuffer; +import java.nio.channels.AsynchronousCloseException; import java.util.LinkedList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -139,25 +140,19 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec private void shutdown() { - // First close then abort, to be sure that the - // connection cannot be reused from an onFailure() - // handler or by blocking code waiting for completion. - close(); - for (HttpChannelOverFCGI channel : channels.values()) - channel.abort(new EOFException()); + close(new EOFException()); } @Override protected boolean onReadTimeout() { - for (HttpChannelOverFCGI channel : channels.values()) - channel.abort(new TimeoutException()); - close(); + close(new TimeoutException()); return false; } - public void release() + protected void release(HttpChannelOverFCGI channel) { + channels.remove(channel.getRequest()); if (destination instanceof PoolingHttpDestination) { @SuppressWarnings("unchecked") @@ -170,16 +165,36 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec @Override public void close() { + close(new AsynchronousCloseException()); + } + + private void close(Throwable failure) + { if (closed.compareAndSet(false, true)) { + // First close then abort, to be sure that the connection cannot be reused + // from an onFailure() handler or by blocking code waiting for completion. getHttpDestination().close(this); getEndPoint().shutdownOutput(); LOG.debug("{} oshut", this); getEndPoint().close(); LOG.debug("{} closed", this); + + abort(failure); } } + protected void abort(Throwable failure) + { + for (HttpChannelOverFCGI channel : channels.values()) + { + HttpExchange exchange = channel.getHttpExchange(); + if (exchange != null) + exchange.getRequest().abort(failure); + } + channels.clear(); + } + private int acquireRequest() { synchronized (requests) @@ -304,7 +319,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec @Override public void onEnd(int request) { - HttpChannelOverFCGI channel = channels.remove(request); + HttpChannelOverFCGI channel = channels.get(request); if (channel != null) { channel.responseSuccess(); |