Issue 5310 - Review HTTP/2 GOAWAY handling.
Refactored reset code in a single place: HTTP2Session.reset(). Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
62e17da2d0
commit
0dc2894002
|
@ -278,7 +278,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
// otherwise other requests will be stalled.
|
// otherwise other requests will be stalled.
|
||||||
flowControl.onDataConsumed(this, null, flowControlLength);
|
flowControl.onDataConsumed(this, null, flowControlLength);
|
||||||
if (isStreamClosed(streamId))
|
if (isStreamClosed(streamId))
|
||||||
reset(new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), callback);
|
reset(null, new ResetFrame(streamId, ErrorCode.STREAM_CLOSED_ERROR.code), callback);
|
||||||
else
|
else
|
||||||
onConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_data_frame", callback);
|
onConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "unexpected_data_frame", callback);
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
int streamSendWindow = stream.updateSendWindow(0);
|
int streamSendWindow = stream.updateSendWindow(0);
|
||||||
if (MathUtils.sumOverflows(streamSendWindow, windowDelta))
|
if (MathUtils.sumOverflows(streamSendWindow, windowDelta))
|
||||||
{
|
{
|
||||||
reset(new ResetFrame(streamId, ErrorCode.FLOW_CONTROL_ERROR.code), Callback.NOOP);
|
reset(stream, new ResetFrame(streamId, ErrorCode.FLOW_CONTROL_ERROR.code), Callback.NOOP);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -642,9 +642,16 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
control(null, callback, frame);
|
control(null, callback, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reset(ResetFrame frame, Callback callback)
|
void reset(IStream stream, ResetFrame frame, Callback callback)
|
||||||
{
|
{
|
||||||
control(getStream(frame.getStreamId()), callback, frame);
|
control(stream, Callback.from(() ->
|
||||||
|
{
|
||||||
|
if (stream != null)
|
||||||
|
{
|
||||||
|
stream.close();
|
||||||
|
removeStream(stream);
|
||||||
|
}
|
||||||
|
}, callback), frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -810,7 +817,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
if (maxCount >= 0 && remoteCount - remoteClosing >= maxCount)
|
if (maxCount >= 0 && remoteCount - remoteClosing >= maxCount)
|
||||||
{
|
{
|
||||||
updateLastRemoteStreamId(streamId);
|
updateLastRemoteStreamId(streamId);
|
||||||
reset(new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP);
|
reset(null, new ResetFrame(streamId, ErrorCode.REFUSED_STREAM_ERROR.code), Callback.NOOP);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (remoteStreamCount.compareAndSet(encoded, remoteCount + 1, remoteClosing))
|
if (remoteStreamCount.compareAndSet(encoded, remoteCount + 1, remoteClosing))
|
||||||
|
@ -1331,15 +1338,6 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
removeStream(stream);
|
removeStream(stream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RST_STREAM:
|
|
||||||
{
|
|
||||||
if (stream != null)
|
|
||||||
{
|
|
||||||
stream.close();
|
|
||||||
removeStream(stream);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PUSH_PROMISE:
|
case PUSH_PROMISE:
|
||||||
{
|
{
|
||||||
// Pushed streams are implicitly remotely closed.
|
// Pushed streams are implicitly remotely closed.
|
||||||
|
@ -1568,7 +1566,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
private void complete()
|
private void complete()
|
||||||
{
|
{
|
||||||
reset(new ResetFrame(streamId, error), getCallback());
|
reset(getStream(streamId), new ResetFrame(streamId, error), getCallback());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.http2;
|
||||||
import java.io.EOFException;
|
import java.io.EOFException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.channels.WritePendingException;
|
import java.nio.channels.WritePendingException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -144,7 +143,7 @@ public class HTTP2Stream extends IdleTimeout implements IStream, Callback, Dumpa
|
||||||
localReset = true;
|
localReset = true;
|
||||||
failure = new EOFException("reset");
|
failure = new EOFException("reset");
|
||||||
}
|
}
|
||||||
session.frames(this, Collections.singletonList(frame), callback);
|
((HTTP2Session)session).reset(this, frame, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean startWrite(Callback callback)
|
private boolean startWrite(Callback callback)
|
||||||
|
|
Loading…
Reference in New Issue