Skip to content

Commit

Permalink
Back out "Convert Marshal_tools to use poll instead of select"
Browse files Browse the repository at this point in the history
Summary:
Original commit changeset: 525f90b319cc

Original Phabricator Diff: D64907234

Reviewed By: vassilmladenov

Differential Revision: D65433270

fbshipit-source-id: 4c7bc3f5edf37abe07af5ed95699fb83a0468597
  • Loading branch information
Catherine Gasnier authored and facebook-github-bot committed Nov 4, 2024
1 parent 5442d2c commit a7927ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion hphp/hack/src/utils/marshal_tools/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(wrapped false)
(modules marshal_tools)
(libraries
poll
sys_utils
utils_core)
(preprocess
(pps lwt_ppx ppx_deriving.std)))
Expand Down
18 changes: 8 additions & 10 deletions hphp/hack/src/utils/marshal_tools/marshal_tools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,10 @@ module RegularWriterReader : REGULAR_WRITER_READER = struct
let ( >>= ) a f = f a

let rec write fd ~buffer ~offset ~size =
match Poll.wait_fd_write_non_intr ~timeout_ms:None fd with
| Error flags -> raise (Poll.Poll_exception flags)
| Ok `Timeout -> 0
| Ok `Ok ->
(* Poll.wait_fd_write_non_intr handles EINTR, but the Unix.write call can also be interrupted. If the write
match Sys_utils.select_non_intr [] [fd] [] (-1.) with
| (_, [], _) -> 0
| _ ->
(* Sys_utils.select_non_intr handles EINTR, but the Unix.write call can also be interrupted. If the write
* is interrupted before any bytes are written, the call fails with EINTR. Otherwise, the call
* succeeds and returns the number of bytes written.
*)
Expand All @@ -128,11 +127,10 @@ module RegularWriterReader : REGULAR_WRITER_READER = struct
* preamble and one or more for the data). Any read after the first might block.
*)
let rec read fd ~buffer ~offset ~size =
match Poll.wait_fd_read_non_intr ~timeout_ms:None fd with
| Error flags -> raise (Poll.Poll_exception flags)
| Ok `Timeout -> 0
| Ok `Ok ->
(* Poll.wait_fd_write_non_intr handles EINTR, but the Unix.read call can also be interrupted. If the read
match Sys_utils.select_non_intr [fd] [] [] (-1.) with
| ([], _, _) -> 0
| _ ->
(* Sys_utils.select_non_intr handles EINTR, but the Unix.read call can also be interrupted. If the read
* is interrupted before any bytes are read, the call fails with EINTR. Otherwise, the call
* succeeds and returns the number of bytes read.
*)
Expand Down
2 changes: 1 addition & 1 deletion hphp/hack/src/utils/sys/poll/poll.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let wait_fd
(flags : Poll.Flags.t) (fd : Unix.file_descr) ~(timeout_ms : int option) :
([ `Ok | `Timeout ], Flags.error list) result =
let timeout = make_poll_timeout_ms timeout_ms in
let poll = Poll.create ~maxfds:1 () in
let poll = Poll.create () in
Poll.set_index poll 0 fd flags;
let _nready = Poll.poll poll 1 timeout in
let rflags = Poll.get_revents poll 0 in
Expand Down

0 comments on commit a7927ed

Please sign in to comment.