Skip to content

Commit 6414a3c

Browse files
committed
ocaml: ensure the notifications fd is set to non-blocking
Since some users have observed spinning, it could be that the system thinks the fd should be blocking but it is actually non-blocking and returning immediately. Signed-off-by: David Scott <dave@recoil.org>
1 parent 3715de4 commit 6414a3c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/mirage_block_ocaml.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,13 @@ let process_one t =
416416
requests and forks background threads to process all the requests. *)
417417
let serve_forever () =
418418
let buf = Bytes.make 1 '\000' in
419-
let request_reader = Lwt_unix.of_unix_file_descr Protocol.request_reader in
419+
(* According to https://ocsigen.org/lwt/3.2.1/api/Lwt_unix non-blocking mode
420+
is fastest, and used by default with Unix pipes. *)
421+
let blocking = false in
422+
let request_reader = Lwt_unix.of_unix_file_descr ~blocking Protocol.request_reader in
420423

421424
let rec loop () =
425+
Lwt_unix.set_blocking request_reader blocking;
422426
Lwt_unix.read request_reader buf 0 1
423427
>>= fun n ->
424428
if n = 0 then begin

0 commit comments

Comments
 (0)