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

[Hotfix] Fix Windows Pipe #15778

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/support/pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ class Pipe : public dmlc::Stream {
public:
#ifdef _WIN32
using PipeHandle = HANDLE;
explicit Pipe(int64_t handle) : handle_(reinterpret_cast<PipeHandle>(handle)) {}
#else
using PipeHandle = int;
#endif
/*! \brief Construct a pipe from system handle. */
explicit Pipe(int64_t handle) : handle_(static_cast<PipeHandle>(handle)) {}
#endif
/*! \brief destructor */
~Pipe() { Flush(); }
using Stream::Read;
Expand All @@ -64,7 +64,7 @@ class Pipe : public dmlc::Stream {
if (size == 0) return 0;
#ifdef _WIN32
DWORD nread;
ICHECK(ReadFile(handle_, static_cast<TCHAR*>(ptr), &nread, nullptr))
ICHECK(ReadFile(handle_, static_cast<TCHAR*>(ptr), size, &nread, nullptr))
<< "Read Error: " << GetLastError();
#else
ssize_t nread;
Expand All @@ -83,7 +83,7 @@ class Pipe : public dmlc::Stream {
if (size == 0) return;
#ifdef _WIN32
DWORD nwrite;
ICHECK(WriteFile(handle_, static_cast<const TCHAR*>(ptr), &nwrite, nullptr) &&
ICHECK(WriteFile(handle_, static_cast<const TCHAR*>(ptr), size, &nwrite, nullptr) &&
static_cast<size_t>(nwrite) == size)
<< "Write Error: " << GetLastError();
#else
Expand Down