Skip to content

Commit

Permalink
fix(sendfile): Flush the out_channel used in the fallback path
Browse files Browse the repository at this point in the history
Fixes ocaml#8284

Signed-off-by: Alan Hu <alanh@ccs.neu.edu>
  • Loading branch information
alan-j-hu committed Jul 28, 2023
1 parent ba8db49 commit 6cbb8d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion otherlibs/stdune/src/io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ module Copyfile = struct
with Unix.Unix_error (EINVAL, "sendfile", _) ->
let ic = Unix.in_channel_of_descr src in
let oc = Unix.out_channel_of_descr dst in
copy_channels ic oc)
copy_channels ic oc;
(* The stdlib's channels are buffered. After writing to oc, flush it.
Note that closing oc by calling Unix.close on its underlying file
descriptor does not flush oc. *)
flush oc)
~finally:(fun () ->
Unix.close src;
Unix.close dst)
Expand Down

0 comments on commit 6cbb8d0

Please sign in to comment.