diff --git a/src/support/pipe.h b/src/support/pipe.h index a2803638e1f3..d869504dc4e9 100644 --- a/src/support/pipe.h +++ b/src/support/pipe.h @@ -45,11 +45,11 @@ class Pipe : public dmlc::Stream { public: #ifdef _WIN32 using PipeHandle = HANDLE; + explicit Pipe(int64_t handle) : handle_(reinterpret_cast(handle)) {} #else using PipeHandle = int; -#endif - /*! \brief Construct a pipe from system handle. */ explicit Pipe(int64_t handle) : handle_(static_cast(handle)) {} +#endif /*! \brief destructor */ ~Pipe() { Flush(); } using Stream::Read; @@ -64,7 +64,7 @@ class Pipe : public dmlc::Stream { if (size == 0) return 0; #ifdef _WIN32 DWORD nread; - ICHECK(ReadFile(handle_, static_cast(ptr), &nread, nullptr)) + ICHECK(ReadFile(handle_, static_cast(ptr), size, &nread, nullptr)) << "Read Error: " << GetLastError(); #else ssize_t nread; @@ -83,7 +83,7 @@ class Pipe : public dmlc::Stream { if (size == 0) return; #ifdef _WIN32 DWORD nwrite; - ICHECK(WriteFile(handle_, static_cast(ptr), &nwrite, nullptr) && + ICHECK(WriteFile(handle_, static_cast(ptr), size, &nwrite, nullptr) && static_cast(nwrite) == size) << "Write Error: " << GetLastError(); #else