From 1038959dbf70800545df319715e5d89dbd8ad8af Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Thu, 1 May 2014 09:27:39 -0700 Subject: [PATCH] uv: update to v0.10.27 --- deps/uv/.mailmap | 8 ++++ deps/uv/AUTHORS | 36 ++++++++++++++ deps/uv/ChangeLog | 30 +++++++++++- deps/uv/include/uv.h | 6 +++ deps/uv/src/unix/error.c | 6 +++ deps/uv/src/unix/kqueue.c | 6 +-- deps/uv/src/unix/linux-core.c | 22 ++++++--- deps/uv/src/unix/process.c | 7 +-- deps/uv/src/version.c | 2 +- deps/uv/src/win/pipe.c | 6 +-- deps/uv/src/win/signal.c | 4 +- deps/uv/src/win/util.c | 1 + deps/uv/test/test-list.h | 4 ++ deps/uv/test/test-spawn.c | 107 ++++++++++++++++++++++++++++++++++++++++++ deps/uv/vcbuild.bat | 19 ++++++-- 15 files changed, 237 insertions(+), 27 deletions(-) diff --git a/deps/uv/.mailmap b/deps/uv/.mailmap index 9975da0..7ece437 100644 --- a/deps/uv/.mailmap +++ b/deps/uv/.mailmap @@ -1,15 +1,23 @@ Alan Gutierrez +Andrius Bentkus Bert Belder Bert Belder Brandon Philips Brian White Brian White +Fedor Indutny Frank Denis Isaac Z. Schlueter +Justin Venus +Keno Fischer +Keno Fischer +Maciej Małecki Marc Schlaich +Rasmus Pedersen Robert Mustacchi Ryan Dahl Ryan Emery +Sam Roberts San-Tai Hsu Saúl Ibarra Corretgé Shigeki Ohtsu diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index dcb9931..060701f 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -94,3 +94,39 @@ Luca Bruno Trevor Norris Oguz Bastemur Alexis Campailla +Justin Venus +Ben Kelly +Kristian Evensen +Sean Silva +Linus MÃ¥rtensson +Navaneeth Kedaram Nambiathan +Brent Cook +Brian Kaisner +Reini Urban +Maks Naumov +Sean Farrell +Christoph Iserlohn +Steven Kabbes +Tenor Biel +Andrej Manduch +Joshua Neuheisel +Yorkie +Sam Roberts +River Tarnell +Nathan Sweet +Dylan Cali +Austin Foxley +Geoffry Song +Benjamin Saunders +Rasmus Pedersen +William Light +Oleg Efimov +Lars Gierth +StarWing +thierry-FreeBSD +Isaiah Norton +Raul Martins +David Capello +Paul Tan +Javier Hernández +Tonis Tiigi diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index b41636d..87c5d99 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,4 +1,32 @@ -2014.02.19, Version 0.10.25 (Stable) +2014.05.02, Version 0.10.27 (Stable) + +Changes since version 0.10.26: + +* windows: fix console signal handler refcount (Saúl Ibarra Corretgé) + +* win: always leave crit section in get_proc_title (Fedor Indutny) + + +2014.04.07, Version 0.10.26 (Stable), d864907611c25ec986c5e77d4d6d6dee88f26926 + +Changes since version 0.10.25: + +* process: don't close stdio fds during spawn (Tonis Tiigi) + +* build, windows: do not fail on Windows SDK Prompt (Marc Schlaich) + +* build, windows: fix x64 configuration issue (Marc Schlaich) + +* win: fix buffer leak on error in pipe.c (Fedor Indutny) + +* kqueue: invalidate fd in uv_fs_event_t (Fedor Indutny) + +* linux: always deregister closing fds from epoll (Geoffry Song) + +* error: add ENXIO for O_NONBLOCK FIFO open() (Fedor Indutny) + + +2014.02.19, Version 0.10.25 (Stable), d778dc588507588b12b9f9d2905078db542ed751 Changes since version 0.10.24: diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index 3978def..7022bc6 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -130,6 +130,12 @@ extern "C" { XX( 57, ENODEV, "no such device") \ XX( 58, ESPIPE, "invalid seek") \ XX( 59, ECANCELED, "operation canceled") \ + XX( 60, EFBIG, "file too large") \ + XX( 61, ENOPROTOOPT, "protocol not available") \ + XX( 62, ETXTBSY, "text file is busy") \ + XX( 63, ERANGE, "result too large") \ + XX( 64, ENXIO, "no such device or address") \ + XX( 65, EMLINK, "too many links") \ #define UV_ERRNO_GEN(val, name, s) UV_##name = val, diff --git a/deps/uv/src/unix/error.c b/deps/uv/src/unix/error.c index 05ab482..f54ffdb 100644 --- a/deps/uv/src/unix/error.c +++ b/deps/uv/src/unix/error.c @@ -104,6 +104,12 @@ uv_err_code uv_translate_sys_error(int sys_errno) { case EROFS: return UV_EROFS; case ENOMEM: return UV_ENOMEM; case EDQUOT: return UV_ENOSPC; + case EFBIG: return UV_EFBIG; + case ENOPROTOOPT: return UV_ENOPROTOOPT; + case ETXTBSY: return UV_ETXTBSY; + case ERANGE: return UV_ERANGE; + case ENXIO: return UV_ENXIO; + case EMLINK: return UV_EMLINK; default: return UV_UNKNOWN; } UNREACHABLE(); diff --git a/deps/uv/src/unix/kqueue.c b/deps/uv/src/unix/kqueue.c index dc64203..124f4fd 100644 --- a/deps/uv/src/unix/kqueue.c +++ b/deps/uv/src/unix/kqueue.c @@ -359,10 +359,10 @@ fallback: void uv__fs_event_close(uv_fs_event_t* handle) { #if defined(__APPLE__) if (uv__fsevents_close(handle)) - uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN); -#else - uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN); #endif /* defined(__APPLE__) */ + { + uv__io_close(handle->loop, &handle->event_watcher); + } uv__handle_stop(handle); diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c index 7a8fcd3..69a60b0 100644 --- a/deps/uv/src/unix/linux-core.c +++ b/deps/uv/src/unix/linux-core.c @@ -99,6 +99,7 @@ void uv__platform_loop_delete(uv_loop_t* loop) { void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { struct uv__epoll_event* events; + struct uv__epoll_event dummy; uintptr_t i; uintptr_t nfds; @@ -106,13 +107,20 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) { events = (struct uv__epoll_event*) loop->watchers[loop->nwatchers]; nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1]; - if (events == NULL) - return; - - /* Invalidate events with same file descriptor */ - for (i = 0; i < nfds; i++) - if ((int) events[i].data == fd) - events[i].data = -1; + if (events != NULL) + /* Invalidate events with same file descriptor */ + for (i = 0; i < nfds; i++) + if ((int) events[i].data == fd) + events[i].data = -1; + + /* Remove the file descriptor from the epoll. + * This avoids a problem where the same file description remains open + * in another process, causing repeated junk epoll events. + * + * We pass in a dummy epoll_event, to work around a bug in old kernels. + */ + if (loop->backend_fd >= 0) + uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &dummy); } diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index ca029b1..19686a2 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -302,7 +302,6 @@ static void uv__process_child_init(uv_process_options_t options, if (use_fd == -1) { uv__write_int(error_fd, errno); - perror("failed to open stdio"); _exit(127); } } @@ -316,7 +315,7 @@ static void uv__process_child_init(uv_process_options_t options, if (fd <= 2) uv__nonblock(fd, 0); - if (close_fd != -1) + if (close_fd >= stdio_count) close(close_fd); } @@ -329,19 +328,16 @@ static void uv__process_child_init(uv_process_options_t options, if (options.cwd && chdir(options.cwd)) { uv__write_int(error_fd, errno); - perror("chdir()"); _exit(127); } if ((options.flags & UV_PROCESS_SETGID) && setgid(options.gid)) { uv__write_int(error_fd, errno); - perror("setgid()"); _exit(127); } if ((options.flags & UV_PROCESS_SETUID) && setuid(options.uid)) { uv__write_int(error_fd, errno); - perror("setuid()"); _exit(127); } @@ -351,7 +347,6 @@ static void uv__process_child_init(uv_process_options_t options, execvp(options.file, options.args); uv__write_int(error_fd, errno); - perror("execvp()"); _exit(127); } diff --git a/deps/uv/src/version.c b/deps/uv/src/version.c index 8ea385e..0c35b1b 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 25 +#define UV_VERSION_PATCH 27 #define UV_VERSION_IS_RELEASE 1 diff --git a/deps/uv/src/win/pipe.c b/deps/uv/src/win/pipe.c index cce1d99..ee0c0f8 100644 --- a/deps/uv/src/win/pipe.c +++ b/deps/uv/src/win/pipe.c @@ -1240,9 +1240,9 @@ static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle, uv__set_artificial_error(loop, UV_EOF); if (handle->read2_cb) { - handle->read2_cb(handle, -1, uv_null_buf_, UV_UNKNOWN_HANDLE); + handle->read2_cb(handle, -1, buf, UV_UNKNOWN_HANDLE); } else { - handle->read_cb((uv_stream_t*) handle, -1, uv_null_buf_); + handle->read_cb((uv_stream_t*) handle, -1, buf); } } @@ -1404,7 +1404,7 @@ void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle, break; } } else { - uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_); + uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf); break; } } diff --git a/deps/uv/src/win/signal.c b/deps/uv/src/win/signal.c index e630cd3..f293835 100644 --- a/deps/uv/src/win/signal.c +++ b/deps/uv/src/win/signal.c @@ -129,8 +129,10 @@ static uv_err_t uv__signal_register_control_handler() { /* If the console control handler has already been hooked, just add a */ /* reference. */ - if (uv__signal_control_handler_refs > 0) + if (uv__signal_control_handler_refs > 0) { + uv__signal_control_handler_refs++; return uv_ok_; + } if (!SetConsoleCtrlHandler(uv__signal_control_handler, TRUE)) return uv__new_sys_error(GetLastError()); diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c index 898dcb4..6e6f620 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -425,6 +425,7 @@ uv_err_t uv_get_process_title(char* buffer, size_t size) { * we must query it with getConsoleTitleW */ if (!process_title && uv__get_process_title() == -1) { + LeaveCriticalSection(&process_title_lock); return uv__new_sys_error(GetLastError()); } diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index f60eab3..c280ca9 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -163,6 +163,7 @@ TEST_DECLARE (spawn_setgid_fails) TEST_DECLARE (spawn_stdout_to_file) TEST_DECLARE (spawn_stdout_and_stderr_to_file) TEST_DECLARE (spawn_auto_unref) +TEST_DECLARE (spawn_closed_process_io) TEST_DECLARE (fs_poll) TEST_DECLARE (kill) TEST_DECLARE (fs_file_noent) @@ -226,6 +227,7 @@ TEST_DECLARE (spawn_setuid_setgid) TEST_DECLARE (we_get_signal) TEST_DECLARE (we_get_signals) TEST_DECLARE (signal_multiple_loops) +TEST_DECLARE (closed_fd_events) #endif #ifdef __APPLE__ TEST_DECLARE (osx_select) @@ -442,6 +444,7 @@ TASK_LIST_START TEST_ENTRY (spawn_stdout_to_file) TEST_ENTRY (spawn_stdout_and_stderr_to_file) TEST_ENTRY (spawn_auto_unref) + TEST_ENTRY (spawn_closed_process_io) TEST_ENTRY (fs_poll) TEST_ENTRY (kill) @@ -458,6 +461,7 @@ TASK_LIST_START TEST_ENTRY (we_get_signal) TEST_ENTRY (we_get_signals) TEST_ENTRY (signal_multiple_loops) + TEST_ENTRY (closed_fd_events) #endif #ifdef __APPLE__ diff --git a/deps/uv/test/test-spawn.c b/deps/uv/test/test-spawn.c index 4388987..3afe0cb 100644 --- a/deps/uv/test/test-spawn.c +++ b/deps/uv/test/test-spawn.c @@ -40,6 +40,7 @@ static char exepath[1024]; static size_t exepath_size = 1024; static char* args[3]; static int no_term_signal; +static int timer_counter; #define OUTPUT_SIZE 1024 static char output[OUTPUT_SIZE]; @@ -118,6 +119,12 @@ static void on_read(uv_stream_t* tcp, ssize_t nread, uv_buf_t buf) { } +static void on_read_once(uv_stream_t* tcp, ssize_t nread, const uv_buf_t buf) { + uv_read_stop(tcp); + on_read(tcp, nread, buf); +} + + static void write_cb(uv_write_t* req, int status) { ASSERT(status == 0); uv_close((uv_handle_t*)req->handle, close_cb); @@ -145,6 +152,11 @@ static void timer_cb(uv_timer_t* handle, int status) { } +static void timer_counter_cb(uv_timer_t* handle, int status) { + ++timer_counter; +} + + TEST_IMPL(spawn_fails) { init_process_options("", exit_cb_failure_expected); options.file = options.args[0] = "program-that-had-better-not-exist"; @@ -664,6 +676,39 @@ TEST_IMPL(spawn_same_stdout_stderr) { } +TEST_IMPL(spawn_closed_process_io) { + uv_pipe_t in; + uv_write_t write_req; + uv_buf_t buf; + uv_stdio_container_t stdio[2]; + static char buffer[] = "hello-from-spawn_stdin"; + + init_process_options("spawn_helper1", exit_cb); + + uv_pipe_init(uv_default_loop(), &in, 0); + options.stdio = stdio; + options.stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; + options.stdio[0].data.stream = (uv_stream_t*) ∈ + options.stdio_count = 1; + + close(0); /* Close process stdin. */ + + ASSERT(0 == uv_spawn(uv_default_loop(), &process, options)); + + buf.base = buffer; + buf.len = sizeof(buffer); + ASSERT(0 == uv_write(&write_req, (uv_stream_t*) &in, &buf, 1, write_cb)); + + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + + ASSERT(exit_cb_called == 1); + ASSERT(close_cb_called == 2); /* process, child stdin */ + + MAKE_VALGRIND_HAPPY(); + return 0; +} + + TEST_IMPL(kill) { int r; uv_err_t err; @@ -1038,3 +1083,65 @@ TEST_IMPL(spawn_auto_unref) { MAKE_VALGRIND_HAPPY(); return 0; } + + +#ifndef _WIN32 +TEST_IMPL(closed_fd_events) { + uv_stdio_container_t stdio[3]; + uv_pipe_t pipe_handle; + int fd[2]; + + /* create a pipe and share it with a child process */ + ASSERT(0 == pipe(fd)); + ASSERT(0 == fcntl(fd[0], F_SETFL, O_NONBLOCK)); + + /* spawn_helper4 blocks indefinitely. */ + init_process_options("spawn_helper4", exit_cb); + options.stdio_count = 3; + options.stdio = stdio; + options.stdio[0].data.fd = fd[0]; + options.stdio[0].flags = UV_INHERIT_FD; + options.stdio[1].flags = UV_IGNORE; + options.stdio[2].flags = UV_IGNORE; + + ASSERT(0 == uv_spawn(uv_default_loop(), &process, options)); + uv_unref((uv_handle_t*) &process); + + /* read from the pipe with uv */ + ASSERT(0 == uv_pipe_init(uv_default_loop(), &pipe_handle, 0)); + ASSERT(0 == uv_pipe_open(&pipe_handle, fd[0])); + fd[0] = -1; + + ASSERT(0 == uv_read_start((uv_stream_t*) &pipe_handle, on_alloc, on_read_once)); + + ASSERT(1 == write(fd[1], "", 1)); + + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + + /* should have received just one byte */ + ASSERT(output_used == 1); + + /* close the pipe and see if we still get events */ + uv_close((uv_handle_t*) &pipe_handle, close_cb); + + ASSERT(1 == write(fd[1], "", 1)); + + ASSERT(0 == uv_timer_init(uv_default_loop(), &timer)); + ASSERT(0 == uv_timer_start(&timer, timer_counter_cb, 10, 0)); + + /* see if any spurious events interrupt the timer */ + if (1 == uv_run(uv_default_loop(), UV_RUN_ONCE)) { + if (1 == uv_run(uv_default_loop(), UV_RUN_ONCE)) + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_ONCE)); + } + + ASSERT(timer_counter == 1); + + /* cleanup */ + ASSERT(0 == uv_process_kill(&process, /* SIGTERM */ 15)); + ASSERT(0 == close(fd[1])); + + MAKE_VALGRIND_HAPPY(); + return 0; +} +#endif /* !_WIN32 */ diff --git a/deps/uv/vcbuild.bat b/deps/uv/vcbuild.bat index 0b7ea48..42b0b94 100644 --- a/deps/uv/vcbuild.bat +++ b/deps/uv/vcbuild.bat @@ -33,7 +33,7 @@ if /i "%1"=="noprojgen" set noprojgen=1&goto arg-ok if /i "%1"=="nobuild" set nobuild=1&goto arg-ok if /i "%1"=="x86" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok if /i "%1"=="ia32" set target_arch=ia32&set platform=WIN32&set vs_toolset=x86&goto arg-ok -if /i "%1"=="x64" set target_arch=x64&set platform=amd64&set vs_toolset=x64&goto arg-ok +if /i "%1"=="x64" set target_arch=x64&set platform=x64&set vs_toolset=x64&goto arg-ok if /i "%1"=="shared" set library=shared_library&goto arg-ok if /i "%1"=="static" set library=static_library&goto arg-ok :arg-ok @@ -41,6 +41,17 @@ shift goto next-arg :args-done +if defined WindowsSDKDir goto select-target +if defined VCINSTALLDIR goto select-target + +@rem Look for Visual Studio 2013 +if not defined VS120COMNTOOLS goto vc-set-2012 +if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2012 +call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" %vs_toolset% +set GYP_MSVS_VERSION=2013 +goto select-target + +:vc-set-2012 @rem Look for Visual Studio 2012 if not defined VS110COMNTOOLS goto vc-set-2010 if not exist "%VS110COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2010 @@ -101,10 +112,8 @@ echo Project files generated. if defined nobuild goto run @rem Check if VS build env is available -if not defined VCINSTALLDIR goto msbuild-not-found -goto msbuild-found - -:msbuild-not-found +if defined VCINSTALLDIR goto msbuild-found +if defined WindowsSDKDir goto msbuild-found echo Build skipped. To build, this file needs to run from VS cmd prompt. goto run -- 2.7.4