Skip to content

Commit

Permalink
tcp, pipe: don't assert on uv_accept() errors
Browse files Browse the repository at this point in the history
It's possible for a new connection to be closed in the window between the
accept() syscall and the call to uv_accept(). Deal with it and move on, don't
assert.
  • Loading branch information
bnoordhuis committed Feb 15, 2012
1 parent 14b20ff commit 0685707
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/pipe_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
PipeWrap* client_wrap =
static_cast<PipeWrap*>(client_obj->GetPointerFromInternalField(0));

int r = uv_accept(handle, (uv_stream_t*)&client_wrap->handle_);

// uv_accept should always work.
assert(r == 0);
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;

// Successful accept. Call the onconnection callback in JavaScript land.
Local<Value> argv[1] = { client_obj };
Expand Down
5 changes: 1 addition & 4 deletions src/tcp_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
TCPWrap* client_wrap =
static_cast<TCPWrap*>(client_obj->GetPointerFromInternalField(0));

int r = uv_accept(handle, (uv_stream_t*)&client_wrap->handle_);

// uv_accept should always work.
assert(r == 0);
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;

// Successful accept. Call the onconnection callback in JavaScript land.
argv[0] = client_obj;
Expand Down

0 comments on commit 0685707

Please sign in to comment.