Skip to content

Commit

Permalink
Always check for ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Feb 4, 2024
1 parent 7f2f464 commit d10ca88
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/cry.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,12 @@ let poll r w timeout =
let poll = Poll.create () in
List.iter (fun fd -> Poll.set poll fd Poll.Event.read) r;
List.iter (fun fd -> Poll.set poll fd Poll.Event.write) w;
match Poll.wait poll timeout with
| `Ok ->
let r = ref [] in
let w = ref [] in
Poll.iter_ready poll ~f:(fun fd -> function
| { Poll.Event.readable = true; _ } -> r := fd :: !r
| _ -> w := fd :: !w);
let r = !r in
let w = !w in
(r, w)
| `Timeout -> ([], [])
ignore (Poll.wait poll timeout);
let r = ref [] in
let w = ref [] in
Poll.iter_ready poll ~f:(fun fd -> function
| { Poll.Event.readable = true; _ } -> r := fd :: !r | _ -> w := fd :: !w);
(!r, !w)

type error =
| Create of exn
Expand Down

0 comments on commit d10ca88

Please sign in to comment.