Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
src: update from uv_read2_start removal
Browse files Browse the repository at this point in the history
Previously if you wanted to be notified of pending handles for pipes
you needed to use uv_read2_start, however in v0.11.22 you can query for
pending handles independently.
  • Loading branch information
tjfontaine committed Mar 11, 2014
1 parent d2f2a32 commit e2fcfea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
21 changes: 8 additions & 13 deletions src/stream_wrap.cc
Expand Up @@ -93,12 +93,7 @@ void StreamWrap::ReadStart(const FunctionCallbackInfo<Value>& args) {

StreamWrap* wrap = Unwrap<StreamWrap>(args.This());

int err;
if (wrap->is_named_pipe_ipc()) {
err = uv_read2_start(wrap->stream(), OnAlloc, OnRead2);
} else {
err = uv_read_start(wrap->stream(), OnAlloc, OnRead);
}
int err = uv_read_start(wrap->stream(), OnAlloc, OnRead);

args.GetReturnValue().Set(err);
}
Expand Down Expand Up @@ -169,15 +164,15 @@ void StreamWrap::OnReadCommon(uv_stream_t* handle,
void StreamWrap::OnRead(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf) {
OnReadCommon(handle, nread, buf, UV_UNKNOWN_HANDLE);
}
StreamWrap* wrap = static_cast<StreamWrap*>(handle->data);
uv_handle_type type = UV_UNKNOWN_HANDLE;

if (wrap->is_named_pipe_ipc() &&
uv_pipe_pending_count(reinterpret_cast<uv_pipe_t*>(handle)) > 0) {
type = uv_pipe_pending_type(reinterpret_cast<uv_pipe_t*>(handle));
}

void StreamWrap::OnRead2(uv_pipe_t* handle,
ssize_t nread,
const uv_buf_t* buf,
uv_handle_type pending) {
OnReadCommon(reinterpret_cast<uv_stream_t*>(handle), nread, buf, pending);
OnReadCommon(handle, nread, buf, type);
}


Expand Down
4 changes: 0 additions & 4 deletions src/stream_wrap.h
Expand Up @@ -178,10 +178,6 @@ class StreamWrap : public HandleWrap {
static void OnRead(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf);
static void OnRead2(uv_pipe_t* handle,
ssize_t nread,
const uv_buf_t* buf,
uv_handle_type pending);
static void OnReadCommon(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf,
Expand Down

0 comments on commit e2fcfea

Please sign in to comment.