unix: clear UV_HANDLE_READING flag before callback
The UV_HANDLE_READING stream flag should be removed before stopping the IO watcher and calling the callback. If the callback calls uv_read_start(), the IO watcher will be started then after the callback the UV_HANDLE_READING flag is removed. This will result in epoll constantly reporting POLLIN events while no one handles it, causing 100% CPU usage. PR-URL: https://github.com/libuv/libuv/pull/2382 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
1bd72eb51f
commit
be8b3513d3
@ -1000,12 +1000,12 @@ uv_handle_type uv__handle_type(int fd) {
|
||||
|
||||
static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) {
|
||||
stream->flags |= UV_HANDLE_READ_EOF;
|
||||
stream->flags &= ~UV_HANDLE_READING;
|
||||
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
|
||||
if (!uv__io_active(&stream->io_watcher, POLLOUT))
|
||||
uv__handle_stop(stream);
|
||||
uv__stream_osx_interrupt_select(stream);
|
||||
stream->read_cb(stream, UV_EOF, buf);
|
||||
stream->flags &= ~UV_HANDLE_READING;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user