diff options
author | Simone Bordet | 2014-04-07 15:51:23 +0000 |
---|---|---|
committer | Simone Bordet | 2014-04-07 15:51:23 +0000 |
commit | 2897027f53297db687edef2aaf2e1a267d98be7d (patch) | |
tree | 1891fd7822785075b0ef64b81a9088e62d7e4179 /jetty-fcgi/fcgi-client | |
parent | 0a748205f045e3f03281d12ecf647d785b9ce70e (diff) | |
parent | cc0775133e13c24b9222181963147f39111669d5 (diff) | |
download | org.eclipse.jetty.project-2897027f53297db687edef2aaf2e1a267d98be7d.tar.gz org.eclipse.jetty.project-2897027f53297db687edef2aaf2e1a267d98be7d.tar.xz org.eclipse.jetty.project-2897027f53297db687edef2aaf2e1a267d98be7d.zip |
Merged branch 'master' into 'jetty-9.2.x'.
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(); |