Skip to content

Commit

Permalink
fix data flush
Browse files Browse the repository at this point in the history
Signed-off-by: dentiny <[email protected]>
  • Loading branch information
dentiny committed Jan 25, 2025
1 parent 025bad1 commit 6e0e559
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/ray/util/pipe_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,18 @@ RedirectionFileHandle OpenFileForRedirection(const std::string &file_path) {
auto ostream =
std::make_shared<boost::iostreams::stream<boost::iostreams::file_descriptor_sink>>(
std::move(sink));
auto flush_fn = [ostream]() { ostream->flush(); };
auto close_fn = [ostream]() {
auto flush_fn = [ostream, handle]() {
// Flush stream internal buffer to fd.
ostream->flush();
// Flush file handle.
#if defined(__APPLE__) || defined(__linux__)
RAY_CHECK_EQ(fdatasync(handle), 0);
#elif defined(_WIN32)
RAY_CHECK_EQ(FlushFileBuffers(handle));
#endif
};
auto close_fn = [flush_fn, ostream]() {
flush_fn();
ostream->close();
};
return RedirectionFileHandle{
Expand Down

0 comments on commit 6e0e559

Please sign in to comment.