unix: fix uv_poll CPU usage spike

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.
This commit is contained in:
Ben Noordhuis 2012-05-23 12:52:42 +02:00
parent b19a713cfc
commit 2e3e658be1

View File

@ -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);