From f336208238d2d3ce04c22eb8c574b50f1843191e Mon Sep 17 00:00:00 2001 From: Leandro Ostera Date: Thu, 21 Dec 2023 16:09:16 +0100 Subject: [PATCH] feat: broaden io ops types to fd --- CHANGES.md | 5 +++++ riot/runtime/net/io.ml | 8 ++++---- riot/runtime/net/io.mli | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7c481e8f..69f6ae1b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Changes +## Unreleased + +* Fix issue with schedulers busy-waiting +* Switch to `poll` to support kqueue on macOS + ## 0.0.5 * Add `register name pid` diff --git a/riot/runtime/net/io.ml b/riot/runtime/net/io.ml index 941e6fc4..a7a425ab 100644 --- a/riot/runtime/net/io.ml +++ b/riot/runtime/net/io.ml @@ -178,15 +178,15 @@ let accept (_t : t) (socket : Fd.t) : accept = | exception Unix.(Unix_error ((EINTR | EAGAIN | EWOULDBLOCK), _, _)) -> `Retry | exception Unix.(Unix_error (reason, _, _)) -> `Abort reason -let read (conn : Socket.stream_socket) buf off len : read = - Fd.use ~op_name:"read" conn @@ fun fd -> +let read (fd : Fd.t) buf off len : read = + Fd.use ~op_name:"read" fd @@ fun fd -> match Unix.read fd buf off len with | len -> `Read len | exception Unix.(Unix_error ((EINTR | EAGAIN | EWOULDBLOCK), _, _)) -> `Retry | exception Unix.(Unix_error (reason, _, _)) -> `Abort reason -let write (conn : Socket.stream_socket) buf off len : write = - Fd.use ~op_name:"write" conn @@ fun fd -> +let write (fd : Fd.t) buf off len : write = + Fd.use ~op_name:"write" fd @@ fun fd -> match Unix.write fd buf off len with | len -> `Wrote len | exception Unix.(Unix_error ((EINTR | EAGAIN | EWOULDBLOCK), _, _)) -> `Retry diff --git a/riot/runtime/net/io.mli b/riot/runtime/net/io.mli index cddc4430..33efba3e 100644 --- a/riot/runtime/net/io.mli +++ b/riot/runtime/net/io.mli @@ -38,5 +38,5 @@ val connect : [> `Abort of Unix.error | `Connected of Fd.t | `In_progress of Fd.t | `Retry ] val accept : t -> Fd.t -> accept -val read : Socket.stream_socket -> bytes -> int -> int -> read -val write : Socket.stream_socket -> bytes -> int -> int -> write +val read : Fd.t -> bytes -> int -> int -> read +val write : Fd.t -> bytes -> int -> int -> write