Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repro #49911

Closed
wants to merge 2 commits into from
Closed

repro #49911

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2725,3 +2725,11 @@ genrule(
""",
local = 1,
)

ray_cc_binary(
name = "pipe",
srcs = ["pipe.cc"],
deps = [
"@boost//:iostreams",
],
)
3 changes: 3 additions & 0 deletions pipe.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <boost/iostreams/device/file_descriptor.hpp>

int main() { return 0; }
1 change: 1 addition & 0 deletions src/ray/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ ray_cc_library(
deps = [
":compat",
":util",
"@boost//:iostreams",
"@com_github_spdlog//:spdlog",
"@com_google_absl//absl/strings",
],
Expand Down
3 changes: 3 additions & 0 deletions src/ray/util/pipe/pipe.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <boost/iostreams/device/file_descriptor.hpp>

int main() { return 0; }
25 changes: 9 additions & 16 deletions src/ray/util/pipe_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "ray/util/pipe_logger.h"

#include <boost/iostreams/device/file_descriptor.hpp>
#include <condition_variable>
#include <cstring>
#include <deque>
Expand Down Expand Up @@ -225,22 +226,14 @@ bool ShouldUsePipeStream(const StreamRedirectionOption &stream_redirect_opt) {

#if defined(__APPLE__) || defined(__linux__)
RedirectionFileHandle OpenFileForRedirection(const std::string &file_path) {
int fd = open(file_path.data(), O_WRONLY | O_CREAT, 0644);
RAY_CHECK_NE(fd, -1) << "Fails to open file " << file_path << " with failure reason "
<< strerror(errno);

auto flush_fn = [fd]() {
RAY_CHECK_EQ(fsync(fd), 0) << "Fails to flush data to disk because "
<< strerror(errno);
};
auto close_fn = [fd]() {
RAY_CHECK_EQ(fsync(fd), 0) << "Fails to flush data to disk because "
<< strerror(errno);
RAY_CHECK_EQ(close(fd), 0) << "Fails to close redirection file because "
<< strerror(errno);
};

return RedirectionFileHandle{fd, std::move(flush_fn), std::move(close_fn)};
boost::iostreams::file_descriptor_sink sink{file_path, std::ios_base::out};
auto handle = sink.handle();
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]() { ostream->close(); };
return RedirectionFileHandle{handle, std::move(flush_fn), std::move(close_fn)};
}
#endif

Expand Down
Loading