diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-10-20 16:13:29 -0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2014-10-20 16:13:29 -0700 |
commit | 35443862a2319c31db50ea540d682f7614d9d959 (patch) | |
tree | 169a1eac69b404ee1f47ac227e4ba7c58af89aa9 | |
parent | 1349b680badeb5d08ad82811af8350dc3e0f0397 (diff) | |
download | node-35443862a2319c31db50ea540d682f7614d9d959.tar.gz |
uv: Update to v0.10.29
-rw-r--r-- | deps/uv/AUTHORS | 1 | ||||
-rw-r--r-- | deps/uv/ChangeLog | 13 | ||||
-rw-r--r-- | deps/uv/config-unix.mk | 1 | ||||
-rw-r--r-- | deps/uv/src/unix/linux-core.c | 21 | ||||
-rw-r--r-- | deps/uv/src/unix/stream.c | 115 | ||||
-rw-r--r-- | deps/uv/src/version.c | 2 | ||||
-rw-r--r-- | deps/uv/src/win/error.c | 1 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 2 | ||||
-rw-r--r-- | deps/uv/test/test-osx-select.c | 47 | ||||
-rw-r--r-- | deps/uv/uv.gyp | 1 |
10 files changed, 160 insertions, 44 deletions
diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 060701ffa..b27d17716 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -130,3 +130,4 @@ David Capello <davidcapello@gmail.com> Paul Tan <pyokagan@gmail.com> Javier Hernández <jhernandez@emergya.com> Tonis Tiigi <tonistiigi@gmail.com> +Michael Hudson-Doyle <michael.hudson@linaro.org> diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index a185a9f3b..3f010a0c3 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,4 +1,15 @@ -2014.07.32, Version 0.10.28 (Stable) +2014.10.21, Version 0.10.29 (Stable) + +Changes since version 0.10.28: + +* darwin: allocate enough space for select() hack (Fedor Indutny) + +* linux: try epoll_pwait if epoll_wait is missing (Michael Hudson-Doyle) + +* windows: map ERROR_INVALID_DRIVE to UV_ENOENT (Saúl Ibarra Corretgé) + + +2014.07.32, Version 0.10.28 (Stable), 9c14b616f5fb84bfd7d45707bab4bbb85894443e Changes since version 0.10.27: diff --git a/deps/uv/config-unix.mk b/deps/uv/config-unix.mk index d230bb257..37c4a72f6 100644 --- a/deps/uv/config-unix.mk +++ b/deps/uv/config-unix.mk @@ -85,6 +85,7 @@ ifeq (__clang__,$(shell sh -c "$(CC) -dM -E - </dev/null | grep -ow __clang__")) CFLAGS += -Wno-dollar-in-identifier-extension endif CPPFLAGS += -D_DARWIN_USE_64_BIT_INODE=1 +CPPFLAGS += -D_DARWIN_UNLIMITED_SELECT=1 LDFLAGS += -framework Foundation \ -framework CoreServices \ -framework ApplicationServices diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c index 69a60b05b..4846bd3fc 100644 --- a/deps/uv/src/unix/linux-core.c +++ b/deps/uv/src/unix/linux-core.c @@ -138,6 +138,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { int fd; int op; int i; + static int no_epoll_wait; if (loop->nfds == 0) { assert(ngx_queue_empty(&loop->watcher_queue)); @@ -184,10 +185,22 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { count = 48; /* Benchmarks suggest this gives the best throughput. */ for (;;) { - nfds = uv__epoll_wait(loop->backend_fd, - events, - ARRAY_SIZE(events), - timeout); + if (!no_epoll_wait) { + nfds = uv__epoll_wait(loop->backend_fd, + events, + ARRAY_SIZE(events), + timeout); + if (nfds == -1 && errno == ENOSYS) { + no_epoll_wait = 1; + continue; + } + } else { + nfds = uv__epoll_pwait(loop->backend_fd, + events, + ARRAY_SIZE(events), + timeout, + NULL); + } /* Update loop->time unconditionally. It's tempting to skip the update when * timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 98e41a308..81933e646 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -53,6 +53,10 @@ struct uv__stream_select_s { int fake_fd; int int_fd; int fd; + fd_set* sread; + size_t sread_sz; + fd_set* swrite; + size_t swrite_sz; }; #endif /* defined(__APPLE__) */ @@ -131,8 +135,6 @@ static void uv__stream_osx_select(void* arg) { uv_stream_t* stream; uv__stream_select_t* s; char buf[1024]; - fd_set sread; - fd_set swrite; int events; int fd; int r; @@ -153,17 +155,17 @@ static void uv__stream_osx_select(void* arg) { break; /* Watch fd using select(2) */ - FD_ZERO(&sread); - FD_ZERO(&swrite); + memset(s->sread, 0, s->sread_sz); + memset(s->swrite, 0, s->swrite_sz); if (uv_is_readable(stream)) - FD_SET(fd, &sread); + FD_SET(fd, s->sread); if (uv_is_writable(stream)) - FD_SET(fd, &swrite); - FD_SET(s->int_fd, &sread); + FD_SET(fd, s->swrite); + FD_SET(s->int_fd, s->sread); /* Wait indefinitely for fd events */ - r = select(max_fd + 1, &sread, &swrite, NULL, NULL); + r = select(max_fd + 1, s->sread, s->swrite, NULL, NULL); if (r == -1) { if (errno == EINTR) continue; @@ -177,7 +179,7 @@ static void uv__stream_osx_select(void* arg) { continue; /* Empty socketpair's buffer in case of interruption */ - if (FD_ISSET(s->int_fd, &sread)) + if (FD_ISSET(s->int_fd, s->sread)) while (1) { r = read(s->int_fd, buf, sizeof(buf)); @@ -198,12 +200,12 @@ static void uv__stream_osx_select(void* arg) { /* Handle events */ events = 0; - if (FD_ISSET(fd, &sread)) + if (FD_ISSET(fd, s->sread)) events |= UV__POLLIN; - if (FD_ISSET(fd, &swrite)) + if (FD_ISSET(fd, s->swrite)) events |= UV__POLLOUT; - assert(events != 0 || FD_ISSET(s->int_fd, &sread)); + assert(events != 0 || FD_ISSET(s->int_fd, s->sread)); if (events != 0) { ACCESS_ONCE(int, s->events) = events; @@ -283,6 +285,10 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) { int ret; int kq; int old_fd; + int max_fd; + size_t sread_sz; + size_t swrite_sz; + int err; kq = kqueue(); if (kq == -1) { @@ -306,30 +312,52 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) { return 0; /* At this point we definitely know that this fd won't work with kqueue */ - s = malloc(sizeof(*s)); - if (s == NULL) - return uv__set_artificial_error(stream->loop, UV_ENOMEM); + + /* + * Create fds for io watcher and to interrupt the select() loop. + * NOTE: do it ahead of malloc below to allocate enough space for fd_sets + */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) + return uv__set_sys_error(stream->loop, errno); + + max_fd = *fd; + if (fds[1] > max_fd) + max_fd = fds[1]; + + sread_sz = (max_fd + NBBY) / NBBY; + swrite_sz = sread_sz; + + s = malloc(sizeof(*s) + sread_sz + swrite_sz); + if (s == NULL) { + err = uv__set_artificial_error(stream->loop, UV_ENOMEM); + goto failed_malloc; + } s->events = 0; s->fd = *fd; + s->sread = (fd_set*) ((char*) s + sizeof(*s)); + s->sread_sz = sread_sz; + s->swrite = (fd_set*) ((char*) s->sread + sread_sz); + s->swrite_sz = swrite_sz; - if (uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb)) { - SAVE_ERRNO(free(s)); - return uv__set_sys_error(stream->loop, errno); - } + err = uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb); + if (err) + goto failed_async_init; s->async.flags |= UV__HANDLE_INTERNAL; uv__handle_unref(&s->async); - if (uv_sem_init(&s->close_sem, 0)) - goto fatal1; - - if (uv_sem_init(&s->async_sem, 0)) - goto fatal2; + err = uv_sem_init(&s->close_sem, 0); + if (err != 0) { + err = uv__set_sys_error(stream->loop, UV_UNKNOWN); + goto failed_close_sem_init; + } - /* Create fds for io watcher and to interrupt the select() loop. */ - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) - goto fatal3; + err = uv_sem_init(&s->async_sem, 0); + if (err != 0) { + err = uv__set_sys_error(stream->loop, UV_UNKNOWN); + goto failed_async_sem_init; + } s->fake_fd = fds[0]; s->int_fd = fds[1]; @@ -339,26 +367,37 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) { stream->select = s; *fd = s->fake_fd; - if (uv_thread_create(&s->thread, uv__stream_osx_select, stream)) - goto fatal4; + err = uv_thread_create(&s->thread, uv__stream_osx_select, stream); + if (err != 0) { + err = uv__set_sys_error(stream->loop, UV_UNKNOWN); + goto failed_thread_create; + } return 0; -fatal4: +failed_thread_create: s->stream = NULL; stream->select = NULL; *fd = old_fd; - close(s->fake_fd); - close(s->int_fd); - s->fake_fd = -1; - s->int_fd = -1; -fatal3: uv_sem_destroy(&s->async_sem); -fatal2: + +failed_async_sem_init: uv_sem_destroy(&s->close_sem); -fatal1: + +failed_close_sem_init: + close(fds[0]); + close(fds[1]); uv_close((uv_handle_t*) &s->async, uv__stream_osx_cb_close); - return uv__set_sys_error(stream->loop, errno); + return err; + +failed_async_init: + free(s); + +failed_malloc: + close(fds[0]); + close(fds[1]); + + return err; } #endif /* defined(__APPLE__) */ diff --git a/deps/uv/src/version.c b/deps/uv/src/version.c index 4267b97cc..ca9640084 100644 --- a/deps/uv/src/version.c +++ b/deps/uv/src/version.c @@ -34,7 +34,7 @@ #define UV_VERSION_MAJOR 0 #define UV_VERSION_MINOR 10 -#define UV_VERSION_PATCH 28 +#define UV_VERSION_PATCH 29 #define UV_VERSION_IS_RELEASE 1 diff --git a/deps/uv/src/win/error.c b/deps/uv/src/win/error.c index 2a72ff2f6..820c2603d 100644 --- a/deps/uv/src/win/error.c +++ b/deps/uv/src/win/error.c @@ -128,6 +128,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) { case ERROR_DIRECTORY: return UV_ENOENT; case ERROR_FILE_NOT_FOUND: return UV_ENOENT; case ERROR_INVALID_NAME: return UV_ENOENT; + case ERROR_INVALID_DRIVE: return UV_ENOENT; case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT; case ERROR_MOD_NOT_FOUND: return UV_ENOENT; case ERROR_PATH_NOT_FOUND: return UV_ENOENT; diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 7930c1c36..474442588 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -232,6 +232,7 @@ TEST_DECLARE (closed_fd_events) #endif #ifdef __APPLE__ TEST_DECLARE (osx_select) +TEST_DECLARE (osx_select_many_fds) #endif HELPER_DECLARE (tcp4_echo_server) HELPER_DECLARE (tcp6_echo_server) @@ -468,6 +469,7 @@ TASK_LIST_START #ifdef __APPLE__ TEST_ENTRY (osx_select) + TEST_ENTRY (osx_select_many_fds) #endif TEST_ENTRY (fs_file_noent) diff --git a/deps/uv/test/test-osx-select.c b/deps/uv/test/test-osx-select.c index bf4c3952b..249614a1f 100644 --- a/deps/uv/test/test-osx-select.c +++ b/deps/uv/test/test-osx-select.c @@ -79,4 +79,51 @@ TEST_IMPL(osx_select) { return 0; } + +TEST_IMPL(osx_select_many_fds) { + int r; + int fd; + size_t i; + size_t len; + const char* str; + struct sockaddr_in addr; + uv_tty_t tty; + uv_tcp_t tcps[1500]; + + addr = uv_ip4_addr("127.0.0.1", 0); + + for (i = 0; i < ARRAY_SIZE(tcps); i++) { + r = uv_tcp_init(uv_default_loop(), &tcps[i]); + ASSERT(r == 0); + r = uv_tcp_bind(&tcps[i], addr); + ASSERT(r == 0); + uv_unref((uv_handle_t*) &tcps[i]); + } + + fd = open("/dev/tty", O_RDONLY); + ASSERT(fd >= 0); + + r = uv_tty_init(uv_default_loop(), &tty, fd, 1); + ASSERT(r == 0); + + r = uv_read_start((uv_stream_t*) &tty, alloc_cb, read_cb); + ASSERT(r == 0); + + /* Emulate user-input */ + str = "got some input\n" + "with a couple of lines\n" + "feel pretty happy\n"; + for (i = 0, len = strlen(str); i < len; i++) { + r = ioctl(fd, TIOCSTI, str + i); + ASSERT(r == 0); + } + + uv_run(uv_default_loop(), UV_RUN_DEFAULT); + + ASSERT(read_count == 3); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + #endif /* __APPLE__ */ diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index 7cd0f7d45..5af99bd59 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -194,6 +194,7 @@ }, 'defines': [ '_DARWIN_USE_64_BIT_INODE=1', + '_DARWIN_UNLIMITED_SELECT=1', ] }], [ 'OS!="mac"', { |