Browse Source

tcp, pipe: don't assert on uv_accept() errors

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.
v0.8.7-release
Ben Noordhuis 13 years ago
parent
commit
0685707bc6
  1. 5
      src/pipe_wrap.cc
  2. 5
      src/tcp_wrap.cc

5
src/pipe_wrap.cc

@ -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 };

5
src/tcp_wrap.cc

@ -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;

Loading…
Cancel
Save