GeezerVison is showing github.com — IoUring:重构写操作的生命周期管理 by dreamlike-ocean · Pull Request #13 · dreamlike-ocean/netty
IoUring:重构写操作的生命周期管理
#13
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
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
137 commits
Select commit
Hold shift + click to select a range
6155c4b
LocalChannel: complete connect() when the accepted channel dies befor…
allthingssecurity Sep 29, 2026
430fdff
Don't leak FixedChannelPool slots on unrelated IllegalArgumentExcepti…
allthingssecurity Sep 29, 2026
9d19e3c
Don't leak queued writes in ChunkedWriteHandler on removal or cancel …
allthingssecurity Sep 29, 2026
e66ce34
Honour the needle's reader index in ByteBufUtil.indexOf(ByteBuf, Byte…
allthingssecurity Sep 30, 2026
4198bde
Close idle outbound HTTP/2 child channels when the parent closes (#17…
allthingssecurity Oct 1, 2026
e6fc471
Only fail in ZlibDecoder when the decompression buffer is full (#17692)
allthingssecurity Oct 1, 2026
44586c5
Fail pending writes of ProxyHandler when it is removed (#17691)
allthingssecurity Oct 1, 2026
d3817ad
Use LocalIoHandler instead of DefaultEventLoop for LocalChannel tests…
normanmaurer Oct 1, 2026
1330f40
Arm force-close timeout when an inbound CLOSE frame is echoed (#17574)
normanmaurer Oct 1, 2026
f364155
Don't count STOMP headers again when the header block is replayed (#1…
allthingssecurity Oct 1, 2026
363d248
Add script that allows to check if a user has signed the icla (#17711)
normanmaurer Oct 1, 2026
9c77622
Complete HTTP/2 graceful close when the connection closes the last st…
allthingssecurity Oct 1, 2026
9afb126
Handle ed25519 and ed448 names in SignatureAlgorithmConverter (#17689)
eager-signal Oct 2, 2026
e7e943d
MqttDecoder accepts malformed MQTT 5 property sections and reclassifi…
normanmaurer Oct 2, 2026
658b570
common: initialize SystemTicker at runtime in native images (#17677)
Asthenia0412 Oct 2, 2026
594e01c
Don't corrupt ChannelOutboundBuffer when a cancelled write makes the …
allthingssecurity Oct 2, 2026
cfed06a
Fail ChunkedNioFile instead of spinning when the file is shorter than…
allthingssecurity Oct 2, 2026
439c831
Validate bzip2 Huffman table selector index before use (#17705)
normanmaurer Oct 2, 2026
70f3035
Reset the permessage-deflate compressor after an empty final fragment…
allthingssecurity Oct 2, 2026
6e1f5f1
Only build and test the affected modules when validating PRs (#17736)
normanmaurer Oct 2, 2026
006a2f1
Fix racy DnsNameResolverTest.testNegativeTtl lifecycle observer check…
normanmaurer Oct 2, 2026
d84dc6b
Fix retainedSlice() of non-retained pooled derived buffers (#17759)
lhotari Oct 5, 2026
2e28f31
Build using powershell on Windows (#17766)
chrisvest Oct 6, 2026
85498e0
Fix quadratic scanning in DelimiterBasedFrameDecoder for non-line del…
normanmaurer Sep 17, 2026
57b80fc
SpdyHttpDecoder: bound cumulative HEADERS frame size per stream
normanmaurer Sep 17, 2026
9b41ea7
Decoded nested HAProxy SSL TLVs re-encode with an inconsistent PROXY …
normanmaurer Sep 11, 2026
da4c183
Release QPACK blocked stream slot when a blocked stream is abandoned
violetagg Sep 29, 2026
faec63c
HTTP1: Stricter multipart per-part Content-Type validation
chrisvest Oct 1, 2026
f4081c5
CorsHandler omits Vary: Origin for the null-origin branch, unlike eve…
normanmaurer Sep 11, 2026
9f49687
HTTP/2: Limit buffered memory for table size changes
ejona86 Sep 23, 2026
4029f07
Correctly handle multiple Content-Length
violetagg Sep 14, 2026
c3f7088
Netty OcspServerCertificateValidator still delivers buffered data fro…
normanmaurer Sep 11, 2026
20f3aae
Fail closed on zero-length handshake records in SslClientHelloHandler
normanmaurer Sep 17, 2026
4cacdf0
Fix quadratic CPU usage in XmlFrameDecoder when an element is never b…
normanmaurer Sep 17, 2026
ef3a3e1
Fix sign-extension bug in SocksInitRequestDecoder NMETHODS field
normanmaurer Sep 21, 2026
6b02cd3
Fix wrong nextBid computation in IoUringBufferRing for RECVSEND_BUNDLE
normanmaurer Sep 24, 2026
bccc62a
Bound domain-name decode buffer to avoid quadratic allocation
normanmaurer Sep 22, 2026
d82c6c3
Fix IP allow-list bypass from ruleType-blind dedup in IpSubnetFilter
normanmaurer Sep 21, 2026
e863e69
Fix io_uring domain socket fd leak on multi-fd SCM_RIGHTS messages
normanmaurer Sep 18, 2026
64cc10f
[maven-release-plugin] prepare release netty-4.2.19.Final
netty-project-bot Oct 6, 2026
014ef8d
[maven-release-plugin] prepare for next development iteration
netty-project-bot Oct 6, 2026
de7fa89
Fix sendmsg_zc leaking IovArray limits and causing empty writev submi…
dreamlike-ocean Oct 11, 2026
1addbf9
Do not let a negatively cached search domain shadow a positive one (#…
akilegaspi Oct 14, 2026
169275f
Fix musl verify job (#17801)
normanmaurer Oct 14, 2026
3eaff63
Reject Redis lines that start with LF (#17793)
yawkat Oct 14, 2026
84c167e
Choose server key types from client's signature algorithms for TLS 1.…
eager-signal Oct 14, 2026
aa00c11
Port 4.2: LocalChannel: Deliver data written by the peer before it cl…
normanmaurer Oct 14, 2026
a3d6289
Validate padding of HEADERS frames without priority (#17817)
bryce-anderson Oct 15, 2026
d18c480
Don't spin in SslHandler.wrapMultiple(...) when the engine consumes n…
allthingssecurity Oct 15, 2026
897ff2e
Preserve invalid SNI names in `ReferenceCountedOpenSslEngine` (#17781)
gavinbunney Oct 15, 2026
d972cae
Optimize redundant bounds checking in ByteBuf.setBytes (#17023)
vpelikh Oct 15, 2026
8ee32af
Respect SETTINGS_QPACK_BLOCKED_STREAMS for unacknowledged QPACK entri…
allthingssecurity Oct 15, 2026
163235f
Release the DNS response when a query future loses a cancel race (#17…
watson-ryan Oct 15, 2026
103787e
Lazily instantiate VarHandle JCTools queues via holder class (#17750)
arnabnandy7 Oct 15, 2026
ff5a1b2
Keep reading a closed QUIC stream until the end of its input (#17755)
allthingssecurity Oct 15, 2026
60d9baf
Throw UnsupportedOperationException from AdaptiveByteBuf.memoryAddres…
normanmaurer Oct 15, 2026
f25d65c
HAProxyMessage: validate the length of all TLV types (#17834)
yawkat Oct 15, 2026
b2df25a
Fix HpackDynamicTable losing entries when filled to capacity (#17831)
yawkat Oct 15, 2026
b23c19d
Make AdaptiveByteBuf.memoryAddress() faster (#17767)
lhotari Oct 15, 2026
491036d
Validate bzip2 Huffman code lengths before building decode tables (#1…
Raghuvardhan-Reddy78 Oct 16, 2026
7071539
Validate header values on DefaultHeaders.copy(), bulk add, entry setV…
normanmaurer Oct 16, 2026
918c7c2
Throw DecompressionException on JdkZlib preset dictionary mismatch (#…
yawkat Oct 16, 2026
8bed05e
Reject HTTP version numbers that overflow int (#17836)
yawkat Oct 16, 2026
fcac457
Apply certificate list size floor (#17674)
arnabnandy7 Oct 16, 2026
b0ffcaf
HAProxyMessageEncoder: encode v1 PROXY UNKNOWN headers (#17837)
yawkat Oct 16, 2026
4a80f41
HAProxyMessage: decode TLVs with an empty value at the end of the hea…
yawkat Oct 16, 2026
a143321
Reject invalid content-length in PUSH_PROMISE with a stream error (#1…
yawkat Oct 16, 2026
46ee86b
Honor maxAllocation for brotli in DelegatingDecompressorFrameListener…
yawkat Oct 16, 2026
27a6921
HAProxyMessageDecoder: fix v2 header framing with a non-zero reader i…
yawkat Oct 16, 2026
afb80a7
IpSubnetFilter: Add tests for overlapping rules (#17765)
Raghuvardhan-Reddy78 Oct 16, 2026
ee7ab44
Avoid allocating NIO buffer views in AdaptiveByteBuf.setBytes(int, By…
lhotari Oct 16, 2026
682d225
Skip JNDI nameserver lookup on IBM i (#17872)
manish-9245 Oct 17, 2026
32de60d
Reset the h2c upgrade stream if the request can not be converted (#17…
yawkat Oct 17, 2026
4aa383f
Don't size ZstdDecoder output buffers from the frame content size (#1…
Raghuvardhan-Reddy78 Oct 18, 2026
1b2300d
Fix NPE in Http2FrameCodec when h2c upgrade fails (#17871)
yawkat Oct 18, 2026
5a6ca7d
Allow adaptive allocator magazine cleanup in BlockHound (#17849)
cj848 Oct 18, 2026
3009c9a
GroupsConverter: fix the x25519mlkem768 group name (#17898)
normanmaurer Oct 18, 2026
098e103
Don't count insertions twice in QPACK Insert Count Increments (#17756)
allthingssecurity Oct 19, 2026
07aed99
Don't lose frames when a delimiter is split across reads (#17665)
allthingssecurity Oct 19, 2026
ecdd3de
Register JFR events only once a Flight Recorder exists (#17614)
yawkat Oct 19, 2026
3ab4fff
Improve OcspServerCertificateValidatorTest.connectUsingHttpAndValidat…
normanmaurer Oct 19, 2026
28d5d02
Don't use the network in OcspClientTest.simpleOcspQueryTest (#17908)
normanmaurer Oct 19, 2026
777eeaa
Read SOCKS5 length octets unsigned in the legacy socks decoders (#17912)
Raghuvardhan-Reddy78 Oct 19, 2026
07153e9
Fix truncated output in Brotli decoders (#17870)
yawkat Oct 19, 2026
e526345
Reject truncated QPACK prefixed integers in field section decode (#17…
Raghuvardhan-Reddy78 Oct 19, 2026
0d74583
Resolve malloc/free via dlsym(RTLD_DEFAULT) in CleanerJava24Linker (#…
jwils Oct 19, 2026
361dd38
Wrap trailing ';' in Content-Disposition as ErrorDataDecoderException…
HwangRock Oct 19, 2026
32eda3a
Auto-port 4.2: Limit the number of queued tasks in NioEventLoopTest.t…
netty-project-bot Oct 20, 2026
20a1bd9
Avoid reflection when obtaining the process ID on Java 9+ (#17873)
zsewasdsdsd Oct 20, 2026
6707372
Keep WINDOW_UPDATE credit of reserved HTTP/2 streams on activation (#…
allthingssecurity Oct 20, 2026
ec8db20
IoUring: Apply IOV_MAX to each write instead of to all writes until s…
dreamlike-ocean Oct 20, 2026
23540b0
Add consistent TLS certificate compression support (#17548)
arnabnandy7 Oct 20, 2026
7c2e7be
Port 4.2: Don't use the network in OcspServerCertificateValidatorTest…
normanmaurer Oct 20, 2026
03eeaca
Avoid unnecessary String allocation in WebSocketServerProtocolHandsha…
fru1tworld Oct 20, 2026
8b2a636
Port 4.2: io_uring: Don't let msgHdrMemoryArray() clear the iovecs of…
normanmaurer Oct 20, 2026
1ed8322
Refresh CA bundle before downloading the aarch64 GCC toolchain (#17948)
normanmaurer Oct 20, 2026
96b5e68
Accept empty non-final fragments in PerMessageDeflateEncoder (#17943)
normanmaurer Oct 20, 2026
154e87c
Exclude the ProcessHandle stub from Surefire in common and buffer (#1…
franz1981 Oct 20, 2026
d6bece5
Verify toolchain downloads in release Dockerfiles against pinned SHA-…
normanmaurer Oct 21, 2026
5776ebc
HTTP/2: Don't pass the close promise to a deferred close (#17955)
idelpivnitskiy Oct 21, 2026
75a5375
Port 4.2: Fix flaky Http2MultiplexTest.unhandledHttp2FramesShouldBePr…
normanmaurer Oct 21, 2026
6511bfb
Fix endless value iterators in ReadOnlyHttpHeaders (#17961)
CCCLL Oct 21, 2026
71ebf52
Hash all 8-byte blocks in SipHash.macHash(...) when position is not 0…
Marti2203 Oct 21, 2026
b7f1c9c
Fix AsciiString.contains(...) false negatives after a partial match (…
CCCLL Oct 21, 2026
b06dfab
Auto-port 4.2: Increase poll timeout in HttpContentCompressorTest.tes…
netty-project-bot Oct 21, 2026
dd5a7e6
Don't invert IP_MULTICAST_LOOP_DISABLED in NioDatagramChannelConfig (…
Marti2203 Oct 21, 2026
570d313
Fix flaky DatagramUnicastIPv6MappedTest on macOS (#17981)
normanmaurer Oct 21, 2026
345af11
Add HpackDecoder test for non-token HTTP/2 header names (#17979)
normanmaurer Oct 21, 2026
9c80298
Don't drop the last character in AsciiString.trim(CharSequence) (#17968)
Marti2203 Oct 21, 2026
19e950b
Fix the region copied by Unpooled.copiedBuffer(CharSequence, int, int…
Marti2203 Oct 21, 2026
192d06e
Port 4.1: Don't invert IP_MULTICAST_LOOP_DISABLED in NioDatagramChann…
normanmaurer Oct 22, 2026
1bf1ac3
Treat DATA frames on reserved HTTP/2 streams as a connection error (#…
yawkat Oct 22, 2026
dc5655e
Http2: reject generic frames whose payload exceeds SETTINGS_MAX_FRAME…
AbhishekShukla1289 Oct 22, 2026
66dc5e6
Don't loop forever in AbstractDiskHttpData when the file is short (#1…
Marti2203 Oct 22, 2026
f69f14a
Check the second gzip magic byte in JdkZlibDecoder (#17972)
Marti2203 Oct 22, 2026
3073066
Reject reply codes with non-digit characters in SmtpResponseDecoder (…
Marti2203 Oct 22, 2026
5f89d65
Return null or the default from read-only headers for invalid values …
CCCLL Oct 22, 2026
bd41b40
MqttEncoder: Reject Variable Byte Integers larger than 268435455 (#17…
normanmaurer Oct 22, 2026
7a6f630
Fix server-initiated WebSocket close handshake failing with "promise …
normanmaurer Oct 22, 2026
e0f2db4
Fix Snappy.encode(...) for input with a non-zero reader index (#18019)
Marti2203 Oct 22, 2026
14d1d84
Fill every remaining byte in the Java 8 SplittableRandom.nextBytes fa…
Marti2203 Oct 22, 2026
12c5eb7
Cancel queued runs and runs of fork PRs when a PR is merged (#18026)
normanmaurer Oct 22, 2026
7999377
Complete the TCP fast open connect before notifying the initial write…
normanmaurer Oct 23, 2026
6ee2740
Only delete socket files when binding and closing UDS channels (#17980)
normanmaurer Oct 23, 2026
01deb17
io_uring: simplify write tracking
dreamlike-ocean Sep 22, 2026
59bb6bc
fix revapi
dreamlike-ocean Sep 22, 2026
2df6164
record WriteOpsSnapshot to reduce allocation
dreamlike-ocean Sep 22, 2026
0ee96be
refactor PendingZeroCopyWrites to reduce allocation
dreamlike-ocean Sep 23, 2026
4e771a3
optimize code
dreamlike-ocean Sep 27, 2026
2e002a8
clean up
dreamlike-ocean Sep 27, 2026
6625587
Reduce WriteOpsSnapshot to fields needed for resource recovery
dreamlike-ocean Sep 28, 2026
a287d57
Move outbound discard hook to Channel.Unsafe
dreamlike-ocean Sep 29, 2026
36fd8d7
add ut
dreamlike-ocean Sep 29, 2026
6e8abea
Defer io_uring sendfd duplication until submission
dreamlike-ocean Sep 29, 2026
e05943b
fix io_uring write tracking after rebasing onto 4.2
dreamlike-ocean Oct 22, 2026
e7fbbbc
keep io_uring discard handling out of core
dreamlike-ocean Oct 23, 2026
187e8db
Report io_uring sendfd dup failures as IOException
dreamlike-ocean Oct 23, 2026
File filter
Filter by extension
.java
(2)
All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
Fail ChunkedNioFile instead of spinning when the file is shorter than…
… requested (netty#17727 )
Motivation:
`ChunkedNioFile` takes its end offset from the constructor arguments, or
from `FileChannel.size()` when it is created. If the file is shorter
when it is read, for example because another process truncated it in the
meantime (or the given length was too large), the positional
`FileChannel.read(...)` returns `-1`. `readChunk(...)` then breaks out
of its loop and returns an empty buffer without advancing `offset`, and
`isEndOfInput()` keeps returning `false` because `offset` never reaches
`endOffset`.
`ChunkedWriteHandler.doFlush0(...)` loops `while
(channel.isWritable())`: it reads the next chunk, writes it, and
continues. Empty buffers never make the channel unwritable, so the loop
never ends and the event loop spins at 100% CPU (with `EmbeddedChannel`,
the outbound queue grows until `OutOfMemoryError`).
`ChunkedFile` fails with an `EOFException` from
`RandomAccessFile.readFully(...)` in the same situation, and
`DefaultFileRegion` was fixed for exactly this problem in netty#8885 (netty#8868 ,
"DefaultFileRegion.transferTo with invalid count may cause busy-spin").
`ChunkedNioFile` is the remaining one; it is what users pick for the SSL
path of a static file server (the example uses `ChunkedFile` there).
Modification:
- In `ChunkedNioFile.readChunk(...)`, throw an `EOFException` when the
file ends before the requested region does, instead of returning what
was read so far. `ChunkedWriteHandler` already fails the write promise
and closes the input when `readChunk(...)` throws.
- Add
`ChunkedWriteHandlerTest.testChunkedFileFailsWhenFileWasTruncated`, a
`@ParameterizedTest` for `ChunkedFile` and `ChunkedNioFile` that
truncates the file after the input was created. An outbound handler
stops the test after 100 writes, so it fails instead of hanging without
the fix.
Result:
A `ChunkedNioFile` whose file is shorter than requested fails the write
with an `EOFException`, like `ChunkedFile`, instead of keeping the event
loop busy forever. Files that are at least as long as the requested
region are read exactly as before.
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit cfed06a0c5359a01b7b0ae4316194d7fbf1b486e
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -21,6 +21,7 @@
import io.netty.channel.FileRegion;
import io.netty.util.internal.ObjectUtil;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
Expand Down
Expand Up
@@ -152,7 +153,11 @@ public ByteBuf readChunk(ByteBufAllocator allocator) throws Exception {
for (;;) {
int localReadBytes = buffer.writeBytes(in, offset + readBytes, chunkSize - readBytes);
if (localReadBytes < 0) {
break;
// The file is shorter than the region we were asked to transfer (for example it was truncated
// after this ChunkedNioFile was created). Fail like ChunkedFile instead of returning empty
// chunks forever, as isEndOfInput() would never return true.
throw new EOFException("Underlying file size " + in.size() + " smaller than requested end " +
"offset " + endOffset);
}
readBytes += localReadBytes;
if (readBytes == chunkSize) {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -31,8 +31,11 @@
import io.netty.util.internal.PlatformDependent;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
Expand Down
Expand Up
@@ -146,6 +149,52 @@ public void close() throws Exception {
});
}
@ParameterizedTest(name = "nio = {0}")
@ValueSource(booleans = { false, true })
public void testChunkedFileFailsWhenFileWasTruncated(boolean nio) throws IOException {
File file = PlatformDependent.createTempFile("netty-chunk-truncated-", ".tmp", null);
file.deleteOnExit();
try (RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
raf.write(BYTES, 0, 1024);
ChunkedInput<ByteBuf> input = nio ? new ChunkedNioFile(raf.getChannel(), 0, 1024, 100) :
new ChunkedFile(raf, 0, 1024, 100);
// The file is truncated after the input was created, for example by another process.
raf.setLength(512);
final AtomicInteger writes = new AtomicInteger();
EmbeddedChannel ch = new EmbeddedChannel(new ChannelOutboundHandlerAdapter() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
if (writes.incrementAndGet() > 100) {
// Stop ChunkedWriteHandler if it keeps writing empty chunks.
ReferenceCountUtil.release(msg);
promise.setFailure(new IllegalStateException("too many writes"));
ctx.close();
return;
}
ctx.write(msg, promise);
}
}, new ChunkedWriteHandler());
ChannelFuture future = ch.writeAndFlush(input);
assertTrue(future.isDone());
assertInstanceOf(EOFException.class, future.cause());
assertEquals(5, writes.get());
int read = 0;
for (;;) {
ByteBuf buffer = ch.readOutbound();
if (buffer == null) {
break;
}
read += buffer.readableBytes();
buffer.release();
}
assertEquals(500, read);
assertFalse(ch.finish());
}
}
@Test
public void testUnchunkedData() throws IOException {
check(Unpooled.wrappedBuffer(BYTES));
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.