Skip to content
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

file descriptor returned by Uring.accept is unusable #117

Open
koonwen opened this issue Jun 24, 2024 · 1 comment
Open

file descriptor returned by Uring.accept is unusable #117

koonwen opened this issue Jun 24, 2024 · 1 comment

Comments

@koonwen
Copy link

koonwen commented Jun 24, 2024

The Uring accept API returns the file descriptor for the accepted socket in result:int as part of

 type 'a completion_option =
  | None
  | Some of { result: int; data: 'a }

However, since the type of Unix.file_descr is abstract, it's unusable with the Unix module API's. My work around is to just use Obj.magic to convert it to the file_descr type, but is this the correct usage pattern?

@talex5
Copy link
Collaborator

talex5 commented Jun 24, 2024

Yes (but check it isn't negative first).

(see also https://discuss.ocaml.org/t/detect-use-after-close-of-unix-file-descriptors/13766/8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants