diff options
author | Simone Bordet | 2015-02-20 17:23:00 +0000 |
---|---|---|
committer | Simone Bordet | 2015-02-20 17:23:31 +0000 |
commit | 58ea526b56637f2396faa944c02aaab8565f5bed (patch) | |
tree | 1e9bbe12822103cae16f3cbb410a96b4b2ac504d /jetty-fcgi/fcgi-client | |
parent | 08b4bd439ed7cfadb78874273081f53c9fccdc4d (diff) | |
download | org.eclipse.jetty.project-58ea526b56637f2396faa944c02aaab8565f5bed.tar.gz org.eclipse.jetty.project-58ea526b56637f2396faa944c02aaab8565f5bed.tar.xz org.eclipse.jetty.project-58ea526b56637f2396faa944c02aaab8565f5bed.zip |
Notifying client connection's promise from onOpen().
The client connection's promise was succeeded in the context of a
call to SelectorManager.newConnection().
This was wrong, since succeeding the promise may trigger the send
of a request *before* the connection is actually linked to the
endPoint and opened.
This change moves the succeeding of the client connection's promise
to the connection onOpen() method.
Diffstat (limited to 'jetty-fcgi/fcgi-client')
2 files changed, 14 insertions, 6 deletions
diff --git a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java index 1491a24066..3e3f7de3ba 100644 --- a/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java +++ b/jetty-fcgi/fcgi-client/src/main/java/org/eclipse/jetty/fcgi/client/http/HttpClientTransportOverFCGI.java @@ -69,15 +69,19 @@ public class HttpClientTransportOverFCGI extends AbstractHttpClientTransport public org.eclipse.jetty.io.Connection newConnection(EndPoint endPoint, Map<String, Object> context) throws IOException { HttpDestination destination = (HttpDestination)context.get(HTTP_DESTINATION_CONTEXT_KEY); - HttpConnectionOverFCGI connection = new HttpConnectionOverFCGI(endPoint, destination, isMultiplexed()); - if (LOG.isDebugEnabled()) - LOG.debug("Created {}", connection); @SuppressWarnings("unchecked") Promise<Connection> promise = (Promise<Connection>)context.get(HTTP_CONNECTION_PROMISE_CONTEXT_KEY); - promise.succeeded(connection); + HttpConnectionOverFCGI connection = newHttpConnection(endPoint, destination, promise); + if (LOG.isDebugEnabled()) + LOG.debug("Created {}", connection); return connection; } + protected HttpConnectionOverFCGI newHttpConnection(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise) + { + return new HttpConnectionOverFCGI(endPoint, destination, promise, isMultiplexed()); + } + protected void customize(Request request, HttpFields fastCGIHeaders) { fastCGIHeaders.put(FCGI.Headers.DOCUMENT_ROOT, getScriptRoot()); 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 0e2e3ddd55..64cf7cba04 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 @@ -46,6 +46,7 @@ import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.CompletableCallback; +import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -56,17 +57,19 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec private final LinkedList<Integer> requests = new LinkedList<>(); private final Map<Integer, HttpChannelOverFCGI> channels = new ConcurrentHashMap<>(); private final AtomicBoolean closed = new AtomicBoolean(); - private final Flusher flusher; private final HttpDestination destination; + private final Promise<Connection> promise; private final boolean multiplexed; + private final Flusher flusher; private final Delegate delegate; private final ClientParser parser; private ByteBuffer buffer; - public HttpConnectionOverFCGI(EndPoint endPoint, HttpDestination destination, boolean multiplexed) + public HttpConnectionOverFCGI(EndPoint endPoint, HttpDestination destination, Promise<Connection> promise, boolean multiplexed) { super(endPoint, destination.getHttpClient().getExecutor()); this.destination = destination; + this.promise = promise; this.multiplexed = multiplexed; this.flusher = new Flusher(endPoint); this.delegate = new Delegate(destination); @@ -95,6 +98,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec { super.onOpen(); fillInterested(); + promise.succeeded(this); } @Override |