From 873b02607c8dd29e7dd8918d661dbd734fc180f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 9 Dec 2014 11:34:23 +0100 Subject: [PATCH] unix: stop reading if an error is produced This aligns the behavior with Windows, where users don't need to call `uv_read_stop` or `uv_close` if they get an error in the read callback. PR-URL: https://github.com/libuv/libuv/pull/47 Reviewed-By: Ben Noordhuis --- src/unix/stream.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/unix/stream.c b/src/unix/stream.c index 18f2db38..757b4080 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -1118,8 +1118,13 @@ static void uv__read(uv_stream_t* stream) { } else { /* Error. User should call uv_close(). */ stream->read_cb(stream, -errno, &buf); - assert(!uv__io_active(&stream->io_watcher, UV__POLLIN) && - "stream->read_cb(status=-1) did not call uv_close()"); + if (stream->flags & UV_STREAM_READING) { + stream->flags &= ~UV_STREAM_READING; + uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN); + if (!uv__io_active(&stream->io_watcher, UV__POLLOUT)) + uv__handle_stop(stream); + uv__stream_osx_interrupt_select(stream); + } } return; } else if (nread == 0) {