Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-10-25 12:21:51 +02:00
commit 7bc856b1a3
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
4 changed files with 35 additions and 10 deletions

View File

@ -410,7 +410,6 @@ public abstract class QuicSession extends ContainerLifeCycle
try
{
endPoints.clear();
flusher.close();
getQuicConnection().outwardClose(this, failure);
}
finally
@ -455,13 +454,6 @@ public abstract class QuicSession extends ContainerLifeCycle
};
}
@Override
public void close()
{
super.close();
timeout.destroy();
}
@Override
protected Action process() throws IOException
{
@ -515,8 +507,7 @@ public abstract class QuicSession extends ContainerLifeCycle
{
if (LOG.isDebugEnabled())
LOG.debug("connection closed {}", QuicSession.this);
cipherBuffer.release();
finishOutwardClose(new ClosedChannelException());
finish(new ClosedChannelException());
}
@Override
@ -524,8 +515,14 @@ public abstract class QuicSession extends ContainerLifeCycle
{
if (LOG.isDebugEnabled())
LOG.debug("failed to write cipher bytes, closing session on {}", QuicSession.this, failure);
finish(failure);
}
private void finish(Throwable failure)
{
cipherBuffer.release();
finishOutwardClose(failure);
timeout.destroy();
}
}

View File

@ -865,7 +865,12 @@ public class ForeignIncubatorQuicheConnection extends QuicheConnection
}
if (written == quiche_error.QUICHE_ERR_DONE)
{
int rc = quiche_h.quiche_conn_stream_writable(quicheConn, streamId, buffer.remaining());
if (rc < 0)
throw new IOException("failed to write to stream " + streamId + "; quiche_err=" + quiche_error.errToString(rc));
return 0;
}
if (written < 0L)
throw new IOException("failed to write to stream " + streamId + "; quiche_err=" + quiche_error.errToString(written));
buffer.position((int)(buffer.position() + written));

View File

@ -310,6 +310,12 @@ public class quiche_h
FunctionDescriptor.of(C_LONG, C_POINTER, C_LONG, C_POINTER, C_LONG, C_CHAR)
);
private static final MethodHandle quiche_conn_stream_writable$MH = downcallHandle(
"quiche_conn_stream_writable",
"(Ljdk/incubator/foreign/MemoryAddress;JJ)I",
FunctionDescriptor.of(C_INT, C_POINTER, C_LONG, C_LONG)
);
private static final MethodHandle quiche_conn_stream_recv$MH = downcallHandle(
"quiche_conn_stream_recv",
"(Ljdk/incubator/foreign/MemoryAddress;JLjdk/incubator/foreign/MemoryAddress;JLjdk/incubator/foreign/MemoryAddress;)J",
@ -670,6 +676,18 @@ public class quiche_h
}
}
public static int quiche_conn_stream_writable(MemoryAddress conn, long stream_id, long buf_len)
{
try
{
return (int) quiche_conn_stream_writable$MH.invokeExact(conn, stream_id, buf_len);
}
catch (Throwable ex)
{
throw new AssertionError("should not reach here", ex);
}
}
public static byte quiche_stream_iter_next(MemoryAddress conn, MemoryAddress stream_id)
{
try

View File

@ -691,7 +691,12 @@ public class JnaQuicheConnection extends QuicheConnection
throw new IOException("connection was released");
int written = LibQuiche.INSTANCE.quiche_conn_stream_send(quicheConn, new uint64_t(streamId), jnaBuffer(buffer), new size_t(buffer.remaining()), last).intValue();
if (written == quiche_error.QUICHE_ERR_DONE)
{
int rc = LibQuiche.INSTANCE.quiche_conn_stream_writable(quicheConn, new uint64_t(streamId), new size_t(buffer.remaining()));
if (rc < 0)
throw new IOException("failed to write to stream " + streamId + "; quiche_err=" + quiche_error.errToString(rc));
return 0;
}
if (written < 0L)
throw new IOException("failed to write to stream " + streamId + "; quiche_err=" + quiche_error.errToString(written));
buffer.position(buffer.position() + written);