Skip to content

Commit

Permalink
[Hotfix] Fix Windows Pipe (#15778)
Browse files Browse the repository at this point in the history
Our cross-platform pipe support is reported to be broken on Windows. See
also: mlc-ai/mlc-llm#930.
  • Loading branch information
junrushao committed Sep 20, 2023
1 parent 9613385 commit 17adc1e
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 17adc1e

Please sign in to comment.