Skip to content

Commit 14bc641

Browse files
gabeleviAvik Chaudhuri
authored and
Avik Chaudhuri
committed
Work around non-blocking fd issue on Windows.
Summary: I reported the Lwt issue here: ocsigen/lwt#574. The long story short is that reading from non-blocking fds on Windows doesn't seem to yield to other threads, even when the fd isn't ready to read. I'm not sure the cause. While we could just revert back to using blocking fds, we'd need to either workaround ocsigen/lwt#569 or ask for a lwt release and update lwt. Reviewed By: ljw1004 Differential Revision: D7603653 fbshipit-source-id: 4af7e806e68cf188c16d199e98801be3b430ac54
1 parent 9eb6c47 commit 14bc641

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hack/utils/marshal_tools_lwt.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ module Marshal_tools_lwt = Marshal_tools.MarshalToolsFunctor (struct
1919
let write ?timeout fd ~buffer ~offset ~size =
2020
if timeout <> None
2121
then raise (Invalid_argument "Use Lwt timeouts directly");
22-
Lwt_unix.write fd buffer offset size
22+
Lwt_unix.wait_write fd
23+
>>= (fun () -> Lwt_unix.write fd buffer offset size)
2324

2425
let read ?timeout fd ~buffer ~offset ~size =
2526
if timeout <> None
2627
then raise (Invalid_argument "Use lwt timeouts directly");
27-
Lwt_unix.read fd buffer offset size
28+
Lwt_unix.wait_read fd
29+
>>= (fun () -> Lwt_unix.read fd buffer offset size)
2830

2931
let log str = Lwt_log_core.ign_error str
3032
end)

0 commit comments

Comments
 (0)