From 2e3e658be1b89d23cad4c126d7e84e2ca1177586 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 23 May 2012 12:52:42 +0200 Subject: [PATCH] unix: fix uv_poll CPU usage spike MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saúl Ibarra Corretgé reports that calling uv_poll_start() repeatedly results in CPU usage spikes. Fixed by stopping the poll I/O watcher before updating it. Fixes #424. --- src/unix/poll.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/poll.c b/src/unix/poll.c index f0a4344e..13796ab5 100644 --- a/src/unix/poll.c +++ b/src/unix/poll.c @@ -100,6 +100,7 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { if (pevents & UV_WRITABLE) events |= UV__IO_WRITE; + uv__io_stop(handle->loop, &handle->io_watcher); uv__io_set(&handle->io_watcher, uv__poll_io, handle->fd, events); uv__io_start(handle->loop, &handle->io_watcher);