-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #12266 - InvocationType improvements and cleanups. #12299
base: jetty-12.1.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
import org.eclipse.jetty.io.AbstractConnection; | ||
import org.eclipse.jetty.io.EndPoint; | ||
import org.eclipse.jetty.util.Attachable; | ||
import org.eclipse.jetty.util.Callback; | ||
import org.eclipse.jetty.util.Promise; | ||
import org.eclipse.jetty.util.thread.Sweeper; | ||
import org.slf4j.Logger; | ||
|
@@ -55,6 +56,7 @@ public class HttpConnectionOverHTTP extends AbstractConnection implements IConne | |
{ | ||
private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionOverHTTP.class); | ||
|
||
private final Callback fillableCallback = new FillableCallback(); | ||
private final AtomicBoolean closed = new AtomicBoolean(); | ||
private final AtomicInteger sweeps = new AtomicInteger(); | ||
private final Promise<Connection> promise; | ||
|
@@ -188,7 +190,7 @@ public void setInitialize(boolean initialize) | |
public void onOpen() | ||
{ | ||
super.onOpen(); | ||
fillInterested(); | ||
setFillInterest(); | ||
boolean initialize = isInitialize(); | ||
if (initialize) | ||
{ | ||
|
@@ -210,6 +212,11 @@ public void onOpen() | |
} | ||
} | ||
|
||
void setFillInterest() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now there is both |
||
{ | ||
fillInterested(fillableCallback); | ||
} | ||
|
||
@Override | ||
public boolean isClosed() | ||
{ | ||
|
@@ -432,4 +439,26 @@ public String toString() | |
return HttpConnectionOverHTTP.this.toString(); | ||
} | ||
} | ||
|
||
private class FillableCallback implements Callback | ||
{ | ||
@Override | ||
public void succeeded() | ||
{ | ||
onFillable(); | ||
} | ||
|
||
@Override | ||
public void failed(Throwable x) | ||
{ | ||
onFillInterestedFailed(x); | ||
} | ||
|
||
@Override | ||
public InvocationType getInvocationType() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the |
||
{ | ||
HttpClientTransport transport = getHttpDestination().getHttpClient().getTransport(); | ||
return transport.getInvocationType(delegate); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
import org.eclipse.jetty.io.RetainableByteBuffer; | ||
import org.eclipse.jetty.util.Attachable; | ||
import org.eclipse.jetty.util.BufferUtil; | ||
import org.eclipse.jetty.util.Callback; | ||
import org.eclipse.jetty.util.Promise; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
@@ -56,6 +57,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements IConne | |
{ | ||
private static final Logger LOG = LoggerFactory.getLogger(HttpConnectionOverFCGI.class); | ||
|
||
private final Callback fillableCallback = new FillableCallback(); | ||
private final ByteBufferPool networkByteBufferPool; | ||
private final AtomicInteger requests = new AtomicInteger(); | ||
private final AtomicBoolean closed = new AtomicBoolean(); | ||
|
@@ -128,10 +130,15 @@ public SendFailure send(HttpExchange exchange) | |
public void onOpen() | ||
{ | ||
super.onOpen(); | ||
fillInterested(); | ||
setFillInterest(); | ||
promise.succeeded(this); | ||
} | ||
|
||
void setFillInterest() | ||
{ | ||
fillInterested(fillableCallback); | ||
} | ||
|
||
@Override | ||
public void onFillable() | ||
{ | ||
|
@@ -492,4 +499,25 @@ private enum State | |
{ | ||
STATUS, HEADERS, CONTENT, COMPLETE | ||
} | ||
|
||
private class FillableCallback implements Callback | ||
{ | ||
@Override | ||
public void succeeded() | ||
{ | ||
onFillable(); | ||
} | ||
|
||
@Override | ||
public void failed(Throwable x) | ||
{ | ||
onFillInterestedFailed(x); | ||
} | ||
|
||
@Override | ||
public InvocationType getInvocationType() | ||
{ | ||
return getHttpDestination().getHttpClient().getTransport().getInvocationType(delegate); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ void receive() | |
HttpConnectionOverFCGI httpConnection = getHttpChannel().getHttpConnection(); | ||
boolean setFillInterest = httpConnection.parseAndFill(true); | ||
if (!hasContent() && setFillInterest) | ||
httpConnection.fillInterested(); | ||
fillInterested(httpConnection); | ||
} | ||
else | ||
{ | ||
|
@@ -86,7 +86,7 @@ public Content.Chunk read(boolean fillInterestIfNeeded) | |
if (chunk != null) | ||
return chunk; | ||
if (needFillInterest && fillInterestIfNeeded) | ||
httpConnection.fillInterested(); | ||
fillInterested(httpConnection); | ||
return null; | ||
} | ||
|
||
|
@@ -138,7 +138,12 @@ private void receiveNext() | |
HttpConnectionOverFCGI httpConnection = getHttpChannel().getHttpConnection(); | ||
boolean setFillInterest = httpConnection.parseAndFill(true); | ||
if (!hasContent() && setFillInterest) | ||
httpConnection.fillInterested(); | ||
fillInterested(httpConnection); | ||
} | ||
|
||
private void fillInterested(HttpConnectionOverFCGI httpConnection) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this helper confusing, inlining it would be clearer IMHO. |
||
{ | ||
httpConnection.setFillInterest(); | ||
} | ||
|
||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import org.eclipse.jetty.server.HttpChannel; | ||
import org.eclipse.jetty.server.HttpConfiguration; | ||
import org.eclipse.jetty.util.Attributes; | ||
import org.eclipse.jetty.util.Callback; | ||
import org.eclipse.jetty.util.StringUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
@@ -42,6 +43,7 @@ public class ServerFCGIConnection extends AbstractMetaDataConnection implements | |
{ | ||
private static final Logger LOG = LoggerFactory.getLogger(ServerFCGIConnection.class); | ||
|
||
private final Callback fillableCallback = new FillableCallback(); | ||
private final HttpChannel.Factory httpChannelFactory = new HttpChannel.DefaultFactory(); | ||
private final Attributes attributes = new Lazy(); | ||
private final Connector connector; | ||
|
@@ -160,7 +162,7 @@ public void clearAttributes() | |
public void onOpen() | ||
{ | ||
super.onOpen(); | ||
fillInterested(); | ||
setFillInterest(); | ||
} | ||
|
||
@Override | ||
|
@@ -188,7 +190,7 @@ public void onFillable() | |
else if (read == 0) | ||
{ | ||
releaseInputBuffer(); | ||
fillInterested(); | ||
setFillInterest(); | ||
return; | ||
} | ||
else | ||
|
@@ -304,11 +306,16 @@ void onCompleted(Throwable failure) | |
{ | ||
releaseInputBuffer(); | ||
if (failure == null) | ||
fillInterested(); | ||
setFillInterest(); | ||
else | ||
getFlusher().shutdown(); | ||
} | ||
|
||
private void setFillInterest() | ||
{ | ||
fillInterested(fillableCallback); | ||
} | ||
|
||
@Override | ||
public boolean onIdleExpired(TimeoutException timeoutException) | ||
{ | ||
|
@@ -418,4 +425,25 @@ public void close() | |
} | ||
super.close(); | ||
} | ||
|
||
private class FillableCallback implements Callback | ||
{ | ||
@Override | ||
public void succeeded() | ||
{ | ||
onFillable(); | ||
} | ||
|
||
@Override | ||
public void failed(Throwable x) | ||
{ | ||
onFillInterestedFailed(x); | ||
} | ||
|
||
@Override | ||
public InvocationType getInvocationType() | ||
{ | ||
return getConnector().getServer().getInvocationType(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this flexibility needed?