Issue #6728 - QUIC and HTTP/3
- Fixed HttpChannelOverHTTP3 input reading. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
fd118a4766
commit
6aedfe52f1
|
@ -297,16 +297,12 @@ public class HttpChannelOverHTTP3 extends HttpChannel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream.Data data = stream.readData();
|
HttpInput.Content result = readContent();
|
||||||
if (data != null)
|
|
||||||
|
if (result != null)
|
||||||
{
|
{
|
||||||
HttpInput.Content result = newContent(data);
|
if (LOG.isDebugEnabled())
|
||||||
try (AutoLock l = lock.lock())
|
LOG.debug("need content read content {} on {}", this.content, this);
|
||||||
{
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("need content read content {} on {}", result, this);
|
|
||||||
content = result;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,40 +318,15 @@ public class HttpChannelOverHTTP3 extends HttpChannel
|
||||||
HttpInput.Content result;
|
HttpInput.Content result;
|
||||||
try (AutoLock l = lock.lock())
|
try (AutoLock l = lock.lock())
|
||||||
{
|
{
|
||||||
if (content != null)
|
result = content;
|
||||||
{
|
|
||||||
result = content;
|
|
||||||
if (!result.isSpecial())
|
|
||||||
content = null;
|
|
||||||
if (LOG.isDebugEnabled())
|
|
||||||
LOG.debug("produced content {} on {}", result, this);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream.Data data = stream.readData();
|
if (result == null)
|
||||||
if (LOG.isDebugEnabled())
|
result = readContent();
|
||||||
LOG.debug("read {} on {}", data, this);
|
|
||||||
if (data == null)
|
if (result == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
result = newContent(data);
|
|
||||||
try (AutoLock l = lock.lock())
|
|
||||||
{
|
|
||||||
content = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean handle = onContent(result);
|
|
||||||
|
|
||||||
boolean isLast = data.isLast();
|
|
||||||
if (isLast)
|
|
||||||
{
|
|
||||||
boolean handleContent = onContentComplete();
|
|
||||||
// This will generate EOF -> must happen before onContentProducible().
|
|
||||||
boolean handleRequest = onRequestComplete();
|
|
||||||
handle |= handleContent | handleRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result.isSpecial())
|
if (!result.isSpecial())
|
||||||
{
|
{
|
||||||
HttpInput.Content newContent = result.isEof() ? new HttpInput.EofContent() : null;
|
HttpInput.Content newContent = result.isEof() ? new HttpInput.EofContent() : null;
|
||||||
|
@ -365,10 +336,41 @@ public class HttpChannelOverHTTP3 extends HttpChannel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("produced new content {} on {}", result, this);
|
LOG.debug("produced content {} on {}", result, this);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HttpInput.Content readContent()
|
||||||
|
{
|
||||||
|
Stream.Data data = stream.readData();
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("read data {} on {}", data, this);
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
HttpInput.Content result = newContent(data);
|
||||||
|
|
||||||
|
boolean handle = onContent(result);
|
||||||
|
|
||||||
|
try (AutoLock l = lock.lock())
|
||||||
|
{
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("read content {} on {}", result, this);
|
||||||
|
content = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.isLast())
|
||||||
|
{
|
||||||
|
boolean handleContent = onContentComplete();
|
||||||
|
// This will generate EOF -> must happen before onContentProducible().
|
||||||
|
boolean handleRequest = onRequestComplete();
|
||||||
|
handle |= handleContent | handleRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private HttpInput.Content newContent(Stream.Data data)
|
private HttpInput.Content newContent(Stream.Data data)
|
||||||
{
|
{
|
||||||
return new DataContent(data);
|
return new DataContent(data);
|
||||||
|
|
|
@ -596,7 +596,7 @@ public class QuicheConnection
|
||||||
if (written == LibQuiche.quiche_error.QUICHE_ERR_DONE)
|
if (written == LibQuiche.quiche_error.QUICHE_ERR_DONE)
|
||||||
return;
|
return;
|
||||||
if (written < 0L)
|
if (written < 0L)
|
||||||
throw new IOException(" failed to write FIN to stream " + streamId + "; err=" + LibQuiche.quiche_error.errToString(written));
|
throw new IOException("failed to write FIN to stream " + streamId + "; err=" + LibQuiche.quiche_error.errToString(written));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,14 +92,14 @@ public class HttpClientLoadTest extends AbstractTest<HttpClientLoadTest.LoadTran
|
||||||
int iterations = 500;
|
int iterations = 500;
|
||||||
for (int i = 0; i < runs; ++i)
|
for (int i = 0; i < runs; ++i)
|
||||||
{
|
{
|
||||||
run(iterations);
|
run(transport, iterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-run after warmup
|
// Re-run after warmup
|
||||||
iterations = 5_000;
|
iterations = 1_000;
|
||||||
for (int i = 0; i < runs; ++i)
|
for (int i = 0; i < runs; ++i)
|
||||||
{
|
{
|
||||||
run(iterations);
|
run(transport, iterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
|
@ -143,10 +143,10 @@ public class HttpClientLoadTest extends AbstractTest<HttpClientLoadTest.LoadTran
|
||||||
int iterations = 256;
|
int iterations = 256;
|
||||||
IntStream.range(0, 16).parallel().forEach(i ->
|
IntStream.range(0, 16).parallel().forEach(i ->
|
||||||
IntStream.range(0, runs).forEach(j ->
|
IntStream.range(0, runs).forEach(j ->
|
||||||
run(iterations)));
|
run(transport, iterations)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(int iterations)
|
private void run(Transport transport, int iterations)
|
||||||
{
|
{
|
||||||
CountDownLatch latch = new CountDownLatch(iterations);
|
CountDownLatch latch = new CountDownLatch(iterations);
|
||||||
List<String> failures = new ArrayList<>();
|
List<String> failures = new ArrayList<>();
|
||||||
|
@ -173,7 +173,7 @@ public class HttpClientLoadTest extends AbstractTest<HttpClientLoadTest.LoadTran
|
||||||
long end = System.nanoTime();
|
long end = System.nanoTime();
|
||||||
task.cancel();
|
task.cancel();
|
||||||
long elapsed = TimeUnit.NANOSECONDS.toMillis(end - begin);
|
long elapsed = TimeUnit.NANOSECONDS.toMillis(end - begin);
|
||||||
logger.info("{} requests in {} ms, {} req/s", iterations, elapsed, elapsed > 0 ? iterations * 1000L / elapsed : -1);
|
logger.info("{} {} requests in {} ms, {} req/s", iterations, transport, elapsed, elapsed > 0 ? iterations * 1000L / elapsed : -1);
|
||||||
|
|
||||||
for (String failure : failures)
|
for (String failure : failures)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue