From b329d51ef4ce32f34c21a016a7c311ddeb077878 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 26 May 2013 23:44:55 +0200 Subject: [PATCH] unix: stop stream POLLOUT watcher on write error The node.js test suite sometimes hits the assert that was added in commit 4146805 that checks if there are connect, write or shutdown requests pending when the user calls uv_read_stop() while the stream is primed for writing. The libuv user (i.e. node.js) is supposed to close the stream on error. Because uv__stream_close() calls uv_read_stop(), it's possible that the POLLOUT watcher is still active. --- src/unix/stream.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/unix/stream.c b/src/unix/stream.c index 892838cc..52972d9c 100644 --- a/src/unix/stream.c +++ b/src/unix/stream.c @@ -798,6 +798,9 @@ start: /* Error */ req->error = errno; uv__write_req_finish(req); + uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT); + if (!uv__io_active(&stream->io_watcher, UV__POLLIN)) + uv__handle_stop(stream); return; } else if (stream->flags & UV_STREAM_BLOCKING) { /* If this is a blocking stream, try again. */