Skip to content

Commit

Permalink
stream: emit EOF instead of ECONNRESET
Browse files Browse the repository at this point in the history
On various platforms, behaviour in return values differs on the read(2)
syscall. On OSX (+ others), read() on a closed-ish socket will return an
EOF, while on FreeBSD (+ others), read() on the same closed-ish socket
will emit an ECONNRESET error.

This commit swallows the ECONNRESET error on the offending platforms to
instead emit an EOF, allowing behaviour to be consistent between
platforms.

Ref: nodejs/node#1885
  • Loading branch information
brendanashworth committed Jun 17, 2015
1 parent 70bbfa0 commit a302dda
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/unix/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,11 @@ static void uv__read(uv_stream_t* stream) {
uv__stream_osx_interrupt_select(stream);
}
stream->read_cb(stream, 0, &buf);
} else if (errno == ECONNRESET) {
/* Use EOF. Platforms differ on read(2) implementation, namely FreeBSD
* returning ECONNRESET when OSX returns EOF.
*/
uv__stream_eof(stream, &buf);
} else {
/* Error. User should call uv_close(). */
stream->read_cb(stream, -errno, &buf);
Expand Down

0 comments on commit a302dda

Please sign in to comment.