Skip to content

Commit

Permalink
feat: broaden io ops types to fd
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Dec 21, 2023
1 parent 4424e48 commit f336208
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
8 changes: 4 additions & 4 deletions riot/runtime/net/io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions riot/runtime/net/io.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f336208

Please sign in to comment.