diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-08-03 16:08:35 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-08-03 16:08:35 +0200 |
commit | 974ee7b3ec5eda30072984dfe3a3838c0def431d (patch) | |
tree | 5af1a8a01c56616fdea0dcdb253354c7665d7f8d | |
parent | 7d7bca64938f91d44c62279171a082a3be6d6027 (diff) | |
download | node-974ee7b3ec5eda30072984dfe3a3838c0def431d.tar.gz |
deps: upgrade libuv to d6a96de
-rw-r--r-- | deps/uv/src/unix/sunos.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/deps/uv/src/unix/sunos.c b/deps/uv/src/unix/sunos.c index e4f48c7a5..3d18058f8 100644 --- a/deps/uv/src/unix/sunos.c +++ b/deps/uv/src/unix/sunos.c @@ -110,7 +110,7 @@ static void uv__fs_event_rearm(uv_fs_event_t *handle) { static void uv__fs_event_read(EV_P_ ev_io* w, int revents) { - uv_fs_event_t *handle; + uv_fs_event_t *handle = NULL; uv_loop_t *loop_; timespec_t timeout; port_event_t pe; @@ -120,15 +120,25 @@ static void uv__fs_event_read(EV_P_ ev_io* w, int revents) { loop_ = container_of(w, uv_loop_t, fs_event_watcher); do { - /* TODO use port_getn() */ + uint_t n = 1; + + /* + * Note that our use of port_getn() here (and not port_get()) is deliberate: + * there is a bug in event ports (Sun bug 6456558) whereby a zeroed timeout + * causes port_get() to return success instead of ETIME when there aren't + * actually any events (!); by using port_getn() in lieu of port_get(), + * we can at least workaround the bug by checking for zero returned events + * and treating it as we would ETIME. + */ do { memset(&timeout, 0, sizeof timeout); - r = port_get(loop_->fs_fd, &pe, &timeout); + r = port_getn(loop_->fs_fd, &pe, 1, &n, &timeout); } while (r == -1 && errno == EINTR); - if (r == -1 && errno == ETIME) + if ((r == -1 && errno == ETIME) || n == 0) break; + handle = (uv_fs_event_t *)pe.portev_user; assert((r == 0) && "unexpected port_get() error"); @@ -143,7 +153,7 @@ static void uv__fs_event_read(EV_P_ ev_io* w, int revents) { } while (handle->fd != PORT_DELETED); - if (handle->fd != PORT_DELETED) + if (handle != NULL && handle->fd != PORT_DELETED) uv__fs_event_rearm(handle); } |