ocaml-uring
ocaml-uring copied to clipboard
file descriptor returned by Uring.accept is unusable
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?
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)