Allow the code to decide if it should use read or read2. #3674

Closed
wants to merge 1 commit into
from
View
4 src/stream_wrap.cc
@@ -132,8 +132,8 @@ Handle<Value> StreamWrap::ReadStart(const Arguments& args) {
UNWRAP(StreamWrap)
- bool ipc_pipe = wrap->stream_->type == UV_NAMED_PIPE &&
- ((uv_pipe_t*)wrap->stream_)->ipc;
+ bool ipc_pipe = (args.Length()>0)?(args[0].IsTrue()):(wrap->stream_->type == UV_NAMED_PIPE &&
+ ((uv_pipe_t*)wrap->stream_)->ipc);
@bnoordhuis
bnoordhuis Jul 9, 2012

One, this is unreadable. Two, what do you think happens when you call uv_read2() on a stream type that doesn't support it?

@VanCoding
VanCoding Jul 9, 2012

I can of course make it more readable & handle errors, too. But only if you are willing to pull it then ;)

int r;
if (ipc_pipe) {
r = uv_read2_start(wrap->stream_, OnAlloc, OnRead2);