Skip to content

io_uring close paths close the fd while a linked RECV can still resolve its number (the #657 fd-lifetime rule, not yet applied to close/hijack/shutdown) #685

Description

@FumingPower3925

Summary

The #657 fix (PR #681) stops the io_uring hand-off from releasing a connection's fd while an operation on it can still resolve the fd. The close paths keep the same shape. They are listed here as the follow-up the #657 design deferred (DECISION step 5). This is found by reading and not observed in any run so far.

  • finishClose / finishCloseDetached submit the connection's cancels (cancelConnOps) and then unix.Close the fd at once. A linked RECV that has not been issued yet (still in the SQ ring, or chained behind a SEND) resolves the fd number when it is issued. By then a new accept may hold that number.
  • hijackConn hands the fd to net.FileConn with only a pending cancel for the armed recv. A recv that completes before the cancel lands takes the hijacker's first bytes.
  • shutdown closes connection fds before tearing down the ring.

On 5.10-5.18 kernels the cancels themselves fail (#682), which makes the close-path case far worse. That half is tracked there. This issue is about the ordering on kernels where the cancels work.

What a fix needs

Related: #657, #682, PR #681.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengine/iouringio_uring engine specifics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions