notify and cleanup when quic connection is refused

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2021-03-24 08:57:26 +01:00 committed by Simone Bordet
parent 29b2f8fa8a
commit a4e4872a9a
3 changed files with 17 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.http3.quiche.QuicheConnectionId;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.RuntimeIOException;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.thread.Scheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -68,6 +69,20 @@ public class ClientQuicConnection extends QuicConnection
fillInterested();
}
@Override
protected void onClose(QuicheConnectionId quicheConnectionId, QuicSession session)
{
super.onClose(quicheConnectionId, session);
InetSocketAddress remoteAddress = session.getRemoteAddress();
if (pendingSessions.remove(remoteAddress) != null)
{
Promise<?> promise = (Promise<?>)context.get(ClientQuicConnector.CONNECTION_PROMISE_CONTEXT_KEY);
if (promise != null)
promise.failed(new IOException("QUIC connection refused"));
}
}
@Override
protected QuicSession createSession(InetSocketAddress remoteAddress, ByteBuffer cipherBuffer)
{

View File

@ -68,7 +68,7 @@ public abstract class QuicConnection extends AbstractConnection
return quicheConfig;
}
protected void onClose(QuicheConnectionId quicheConnectionId)
protected void onClose(QuicheConnectionId quicheConnectionId, QuicSession session)
{
if (quicheConnectionId != null)
sessions.remove(quicheConnectionId);

View File

@ -239,7 +239,7 @@ public abstract class QuicSession
endpoints.values().forEach(AbstractEndPoint::close);
endpoints.clear();
flusher.close();
connection.onClose(quicheConnectionId);
connection.onClose(quicheConnectionId, this);
LifeCycle.stop(strategy);
}
finally