Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
leostera committed Dec 24, 2023
1 parent 7427fb4 commit 105c0e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions riot/lib/io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ module Reader = struct

let read : type src. src t -> buf:Buffer.t -> (int, [> `Closed ]) result =
fun (Reader ((module R), src)) ~buf ->
Logger.trace(fun f -> f " IO.Reader.read");
match R.read src ~buf with
| Ok len -> Ok len
| Error `Eof -> Ok 0
Expand Down
5 changes: 1 addition & 4 deletions riot/lib/net.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ end
module Socket = struct
include Runtime.Net.Socket

module Logger = Logger.Make (struct
let namespace = [ "riot"; "net"; "socket" ]
end)

type listen_opts = {
reuse_addr : bool;
reuse_port : bool;
Expand Down Expand Up @@ -108,6 +104,7 @@ module Socket = struct
let controlling_process _socket ~new_owner:_ = Ok ()

let rec receive ?(timeout = Infinity) ~buf socket =
Logger.trace (fun f ->f "Riot.Net.Socket.receive");
match Low_level.readv socket [| Io.Buffer.as_cstruct buf |] with
| exception Fd.(Already_closed _) -> Error `Closed
| `Abort reason -> Error (`Unix_error reason)
Expand Down
5 changes: 3 additions & 2 deletions riot/runtime/net/io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,15 @@ let write (fd : Fd.t) buf off len : write =
external riot_readv : Unix.file_descr -> Cstruct.t array -> int
= "caml_riot_posix_readv"

let readv (fd : Fd.t) (cs : Cstruct.t array) : read =
let rec readv (fd : Fd.t) (cs : Cstruct.t array) : read =
Fd.use ~op_name:"readv" fd @@ fun unix_fd ->
Log.debug (fun f -> f "Readv-ing from fd=%a" Fd.pp fd);
match riot_readv unix_fd cs with
| len ->
Log.debug (fun f -> f "read %d bytes from fd=%a" len Fd.pp fd);
`Read len
| exception Unix.(Unix_error ((EINTR | EAGAIN | EWOULDBLOCK), _, _)) -> `Retry
| exception Unix.(Unix_error (EINTR, _, _)) -> readv fd cs
| exception Unix.(Unix_error ((EAGAIN | EWOULDBLOCK), _, _)) -> `Retry
| exception Unix.(Unix_error (reason, _, _)) -> `Abort reason

external riot_writev : Unix.file_descr -> Cstruct.t array -> int
Expand Down

0 comments on commit 105c0e6

Please sign in to comment.