Skip to content

Commit 0685707

Browse files
committed
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.
1 parent 14b20ff commit 0685707

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/pipe_wrap.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,7 @@ void PipeWrap::OnConnection(uv_stream_t* handle, int status) {
204204
PipeWrap* client_wrap =
205205
static_cast<PipeWrap*>(client_obj->GetPointerFromInternalField(0));
206206

207-
int r = uv_accept(handle, (uv_stream_t*)&client_wrap->handle_);
208-
209-
// uv_accept should always work.
210-
assert(r == 0);
207+
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;
211208

212209
// Successful accept. Call the onconnection callback in JavaScript land.
213210
Local<Value> argv[1] = { client_obj };

src/tcp_wrap.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
366366
TCPWrap* client_wrap =
367367
static_cast<TCPWrap*>(client_obj->GetPointerFromInternalField(0));
368368

369-
int r = uv_accept(handle, (uv_stream_t*)&client_wrap->handle_);
370-
371-
// uv_accept should always work.
372-
assert(r == 0);
369+
if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;
373370

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

0 commit comments

Comments
 (0)