ocaml-multicore / ocaml-uring

Bindings to io_uring for OCaml
ISC License
62 stars 17 forks source link

file descriptor returned by Uring.accept is unusable #117

Open koonwen opened 4 months ago

koonwen commented 4 months ago

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 commented 4 months ago

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)