Repository navigation
Port5.0 IoUring:Refactor io_uring write lifecycle management - #18154
Merged
Merged
Conversation
✅ All tests passed ✅🏷️ Commit: 277d1ab Learn more about TestLens at testlens.app/docs. |
Member
|
@dreamlike-ocean some stuff to address: |
Member
Author
This doesn't leak. The if ((flags & Native.IORING_CQE_F_MORE) == 0 && --outstandingCompletions == 0 && removeLater) {
remove();
}A close after the primary CQE only sets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation:
This is not a 1:1 port of #17757.
In 4.2, a user-called
shutdownOutput()clears the outbound buffer synchronously while writes may still be in flight, so 4.2 retains the in-flight buffers indoShutdownOutput(). The 5.0 core does not have this problem:shutdown(Outbound)never touches the outbound buffer.shutdownOutput()is only reached fromhandleWriteError, either before a write is submitted or from the CQE of the last in-flight write, so the kernel no longer uses any of the buffers.close()waits for in-flight writes before clearing the outbound buffer.So retaining on shutdown, as both 4.2 and the previous
WriteOperationTrackerdid, protects nothing in 5.0.The only place where 5.0 releases buffers that are still in flight is the inactive flush:
writeFlushedNow()callsfailFlushed()on an inactive channel. This happens during a TCP Fast Open connect, and after a datagramdisconnect()whilesendmsgs are in flight.Modification:
WriteOpsSnapshotreplacesWriteOperationTracker.PendingZeroCopyWritesholds zero-copy buffers until the notification arrives.connectIdchanges.MsgHdrMemory.isWriteFlushedScheduled(), the 5.0 counterpart of the 4.2flush0()override.doShutdown(Outbound)no longer retains anything.Channel.Unsafe, and stream channels are merged intoIoUringSocketChannel.IoUringShutdownOutputDuringInFlight{Write,Splice}Testnow expectrefCnt == 1after shutdown.Result:
In-flight write buffers are retained only where 5.0 actually releases them early, and ordinary writes only copy a few primitive fields into
WriteOpsSnapshotinstead of recording references.